Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

execve(2)

wait(2)

FORK(2)                              BSD                               FORK(2)



NAME
     fork - create a new process

SYNOPSIS
     pid = fork()
     int pid;

DESCRIPTION
     fork creates a new process that is a descendant of the process that calls
     fork.  With the following exceptions, the new (child) process is an exact
     copy of the calling (parent) process.

     ⊕  The child process has a unique process ID.

     ⊕  The child process has a different parent process ID (that is, the
        process ID of the parent process).

     ⊕  The child process has its own copy of the parent's descriptors.  These
        descriptors reference the same underlying objects.  For instance, file
        pointers in file objects are shared between the child and the parent
        so that an lseek(2) on a descriptor in the child process can affect a
        subsequent read(2) or write(2) by the parent.  Shells copy descriptors
        in this way to establish standard input and output for newly created
        processes, as well as to set up pipes.

     ⊕  The child processes resource utilizations are set to 0; see
        getrlimit(2).

ERRORS
     fork will fail and no child process will be created if any of the
     following are true:

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

     [EAGAIN]   The system-imposed limit MAXUPRC (<sys/param.h>) on the total
                number of processes under execution by a single user would be
                exceeded.

     [ENOMEM]   There is insufficient backing storage for the new process.

DIAGNOSTICS
     Upon successful completion, fork returns 0 to the child process and
     returns the child's process ID to the parent process.  Otherwise, -1 is
     returned to the parent process, no child process is created, and errno is
     set to indicate the error.

NOTES
     Programs which open streams using Domain/OS calls and then fork() may not
     work as expected.  From the mbx system calls, for instance, handles
     aren't reference counted.  Similar incompatibilities with fork() exist
     among the gpr and gpio Domain/OS calls.  (Streams opened with the ios
     Domain/OS calls are compatible with fork().)

SEE ALSO
     execve(2), wait(2).
     Domain/OS Call Reference.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026