1 .\" Copyright (c) 1980 Regents of the University of California.
2 .\" All rights reserved. The Berkeley software License Agreement
3 .\" specifies the terms and conditions for redistribution.
5 .\" @(#)fork.2 6.4 (Berkeley) 5/22/86
7 .TH FORK 2 "May 22, 1986"
10 fork \- create a new process
14 #include <sys/types.h>
26 causes creation of a new process.
27 The new process (child process) is an exact copy of the
28 calling process except for the following:
31 The child process has a unique process ID.
33 The child process has a different parent process ID (i.e.,
34 the process ID of the parent process).
36 The child process has its own copy of the parent's descriptors.
37 These descriptors reference the same underlying objects, so that,
38 for instance, file pointers in file objects are shared between
39 the child and the parent, so that an
41 on a descriptor in the child process can affect a subsequent
46 This descriptor copying is also used by the shell to
47 establish standard input and output for newly created processes
48 as well as to set up pipes.
50 The child starts with no pending signals and an inactive alarm timer.
53 Upon successful completion, \fBfork\fP returns a value
54 of 0 to the child process and returns the process ID of the child
55 process to the parent process. Otherwise, a value of \-1 is returned
56 to the parent process, no child process is created, and the global
57 variable \fBerrno\fP is set to indicate the error.
60 will fail and no child process will be created if one or more of the
64 The system-imposed limit on the total
65 number of processes under execution would be exceeded.
66 This limit is configuration-dependent.
67 (The kernel variable NR_PROCS in <minix/config.h> (Minix), or
68 <minix/const.h> (Minix-vmd).)
71 There is insufficient (virtual) memory for the new process.