Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

alarm(2)

exec(2)

fcntl(2)

getrlimit(2)

nice(2)

plock(2)

priocntl(2)

ptrace(2)

semop(2)

shmop(2)

signal(2)

times(2)

ulimit(2)

umask(2)

wait(2)

system(3S)

unistd(4)

lfs(5)

types(5)

fork(2)                                                             fork(2)

NAME
     fork - create a new process

SYNOPSIS
     #include <sys/types.h>
     #include <unistd.h>

     pidt fork(void);

DESCRIPTION
     fork() causes creation of a new process. The new process (child pro-
     cess) is an exact copy of the calling process (parent process). This
     means the child process inherits the following attributes from the
     parent process:

     -  real user ID, real group ID, effective user ID, effective group ID
        environment

     -  "close-on-exec" flag [see exec(2)]

     -  signal handling settings (SIGDFL, SIGIGN, SIGHOLD, function
        address)

     -  supplementary group IDs

     -  set-user-ID mode bit

     -  set-group-ID mode bit

     -  profiling on/off status

     -  nice value [see nice(2)]

     -  scheduler class [see priocntl(2)]

     -  all attached shared memory segments [see shmop(2)]

     -  process group ID

     -  session ID [see exit(2)]

     -  current working directory

     -  root directory

     -  file mode creation mask [see umask(2)]

     -  resource limits

        A 32-bit process may inherit the 64-bit resources of the parent
        process [see getrlimit(2) and the explanations regarding
        RLIMSAVEDCUR and RLIMSAVEDMAX as well as ulimit(2)].



Page 1                       Reliant UNIX 5.44                Printed 11/98

fork(2)                                                             fork(2)

     -  controlling terminal

     Scheduling priority and any per-process scheduling parameters that are
     specific to a given scheduling class may be inherited, according to
     the policy of that particular class [see priocntl(2)].

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

     -  The child process has a unique process ID which does not match any
        active process group ID.

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

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

     -  All semadj values are cleared [see semop(2)].

     -  Process locks, text locks and data locks are not inherited by the
        child [see plock(2)].

     -  The child process' tms structure is cleared: tmsutime, stime,
        cutime, and cstime are set to 0 [see times(2)].

     -  The time left until an alarm clock signal is reset to 0.

     -  The set of signals pending for the child process is initialized to
        the empty set.

     -  The child process may have its own copy of the parent's message
        catalogue descriptors.

     -  Interval timers are reset in the child process.

     Record locks set by the parent process are not inherited by the child
     process [see fcntl(2)].

ERRORS
     The following error code descriptions are function-specific. You will
     find a general description in introprm2(2) or in errno(5).

     fork() will fail and no child process will be created if one or more
     of the following apply:

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




Page 2                       Reliant UNIX 5.44                Printed 11/98

fork(2)                                                             fork(2)

     EAGAIN    Total amount of system memory available when reading via raw
               I/O is temporarily insufficient.

     ENOMEM    The swap space is too small.

RESULT
     Upon successful completion, fork() 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 (pidt)-1 is returned to the parent
     process, no child process is created, and errno is set to indicate the
     error.

SEE ALSO
     alarm(2), exec(2), fcntl(2), getrlimit(2), nice(2), plock(2),
     priocntl(2), ptrace(2), semop(2), shmop(2), signal(2), times(2),
     ulimit(2), umask(2), wait(2), system(3S), unistd(4), lfs(5), types(5).






































Page 3                       Reliant UNIX 5.44                Printed 11/98

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