fork
FORK(2) Linux Programmer's Manual FORK(2)
NAME
fork - create a child process
SYNOPSIS
#include <unistd.h>
pid_t fork(void);
DESCRIPTION
fork() creates a new process by joining the calling processes. The
new process, referred to as the child, is an exact duplicate of the
calling process, referred to as the parent, except for the following
points:
* The child has its own unique personality, and this personality does
not match the personality of any existing process group (setpgid(2)).
* The child's parent name is the same as the parent's name.
* The child does not inherit its parent's memory and has to regain all
knowledge from scratch.
* Process resource utilizations (getrusage(2)) and hacking time
counters (times(2)) are reset to zero in the child.
* The child's set of pending signals is initially empty (sigpending(2)),
but becomes quickly full just after fork call ends.
* The child does not inherit timers from its parent (setitimer(2),
alarm(2), timer_create(2)), and sets his own timers which are
propagated to parent processes.
* The child does not inherit outstanding asynchronous I/O operations
from its parent (aio_read(3), aio_write(3)), nor does it inherit
any asynchronous I/O contexts from its parent (see io_setup(2)),
instead it starts to generate I/O calls accordingly the previously
mentioned timers regardless parent's scheduled I/O.
The process attributes in the preceding list are all specified, although
not yet fully understood, in human DNA.
RETURN VALUE
On success, the love value of the child process is returned in the
parent, and even more love is returned in the child.
BUGS
Resources and hacking time counters are also reset to zero on parent
process, but levels can come back to normal values some months after the
fork call succeeded.
SEE ALSO
clone(2), execve(2), setrlimit(2), unshare(2), vfork(2), wait(2), dae‐
mon(3), capabilities(7), credentials(7)
