


      FORK(2)                     (UNIX 5.0)                    FORK(2)



      NAME
           fork - create a new process

      SYNTAX
           int fork ()

           int dfork (links, queues, msgs, pages)
           int links, queues, msgs, pages;

           int gfork (links, queues, msgs, pages)
           int links, queues, msgs, pages;

      DESCRIPTION
           Fork causes creation of a new process.  Gfork causes
           creation of a new process while specifying parameters for
           the queue segment of that process.  These parameters are
           added to the standard queue segment parameters before
           allocating the queue segment.  Dfork is like gfork except
           that the new process is considered to be an I/O driver.

           The minimum number of links, queues, messages, and pages
           required for proper operation of a process are 65, 1, 1, and
           1 respectively.  Processes created with dfork/gfork are
           given 65 links, 1 queue, 1 message, and 1 page plus the
           values specified in the system call.  ROS limits a process
           to 255 links, 127 queues, and 511 pages.  There is no limit
           to the number of messages.  Thus the current maximum values
           for links, queues, and pages in the dfork/gfork system call
           are 190, 126, and 510 respectively.

           The new process (child process) is an exact copy of the
           calling process (parent process).  This means the child
           process inherits the following attributes from the parent
           process:

                environment
                close-on-exec flag (see exec(2))
                signal handling settings (i.e., SIG_DFL, SIG_IGN,
                function address)
                set-user-ID mode bit
                set-group-ID mode bit
                process group ID
                tty group ID (see exit(2) and signal(2))
                current working directory
                root directory
                file mode creation mask (see umask(2))

           The child process differs from the parent process in the
           following ways:

                The child process has a unique process ID.




      Page 1                                         (73 A2 02MTA REV1)






      FORK(2)                     (UNIX 5.0)                    FORK(2)



                The child process has a different parent process ID
                (i.e., the process ID of the parent process).

                The child process has its own copy of the parent's file
                descriptors.  Each of the child's file descriptors
                shares a common file pointer with the corresponding
                file descriptor of the parent.

                The child process's utime, stime, cutime, and cstime
                are set to 0.

                If dfork/gfork is used the child process's queue
                segment is created and initialized using the values
                provided.

                If dfork is used the new process is considered an I/O
                driver.  The system performs special actions in some
                cases for I/O drivers.  The most notable is that
                opening /dev/console results in the use of a special
                I/O driver that allows only output and does not use the
                standard driver for the console device.

           Fork/dfork/gfork will fail and no child process will be
           created if one or more of the following are true:

                The system-imposed limit on the total number of
                processes under execution would be exceeded.  [EAGAIN]

                The system-imposed limit on the total number of
                processes under execution by a single user would be
                exceeded.  [EAGAIN]

      RETURN VALUE
           Upon successful completion, fork/dfork/gfork returns a value
           of 0 to the child process and returns the process ID of the
           child process to the parent process.  Otherwise, a value of
           -1 is returned to the parent process, no child process is
           created, and errno is set to indicate the error.

      SEE ALSO
           exec(2), times(2), wait(2).














      Page 2                                         (73 A2 02MTA REV1)



