Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
OSS Porting Considerations
Open System Services Porting Guide520573-006
6-18
Performing File Operations
into a zombie process. This may not be the case in other implementations of UNIX. For
example, in SVR4 UNIX, zombies are not created if SIGCHLD is ignored. To avoid
wasting system resources when terminating child processes and ignoring SIGCHLD,
you should take specific action to avoid the creation of zombie processes.
The POSIX.1 standard recommends that portable applications that create child
processes include signal-catching routines that call the wait() or waitpid()
function to receive notification of the termination of child processes. This avoids the
creation of a zombie process when a child process terminates.
Section 3 of the Open System Services Programmer’s Guide contains an example of a
programming technique for preventing zombie processes when child processes
terminate. In the example program, the child process uses the fork() function to
create a duplicate of itself as a grandchild process and immediately terminates. Then,
when the grandchild process terminates, it cannot become a zombie process because
its parent has already terminated. This technique is recommended for portable
programs, since it will work for any implementation of SIGCHLD.
Performing File Operations
This subsection discusses file operations such as opening and creating files and
directories and enabling file caching. Like process operations, there is associated
system overhead involved with these operations. If the code you are porting performs a
great deal of opening and closing of small files as a common manner of execution, you
may want to modify some of your code, in line with some of the performance
considerations discussed in this section.
The OSS name server is key to all pathname-oriented functions: for example, using the
OSS open(), creat(), readdir(), and stat() function calls. The OSS name
server creates and finds inodes (identification nodes), and it translates a name to a file
system ID. It keeps the names and the directory hierarchy in a database and shares
management of regular disk files with Disk Process 2 (DP2).
In addition, the OSS name server shares the management of /dev/tty with Telserv,
shares the management of /dev/null with the OSS file system, and shares the
management of FIFOs with the OSS pipe server.
For a detailed comparison of the Guardian and OSS file systems, including topics such
as file management, file system functions, and interfacing with Guardian and OSS
APIs, refer to the discussion on managing files in the Open System Services
Programmers Guide.