43 lines
1.0 KiB
Groff
43 lines
1.0 KiB
Groff
.TH FORK 2
|
|
.UC 4
|
|
.SH NAME
|
|
fork \- create a child process
|
|
.SH SYNOPSIS
|
|
.nf
|
|
.B #include <unistd.h>
|
|
.B int fork(void);
|
|
.fi
|
|
.SH DESCRIPTION
|
|
.B fork()
|
|
creates a child process the differs from the parent process only in its PID.
|
|
On success, the PID of the child process is returned in the parent's
|
|
thread of execution, and a 0 is returned in the child's thread of execution.
|
|
On failure, a negative value will be returned in the parent's
|
|
context and no child process will be created.
|
|
.PP
|
|
Under linux,
|
|
.B fork()
|
|
is implemented using copy on write pages, so the only
|
|
penalty incured by fork is the time and memory required
|
|
to duplicate the parent's page tables, and to create a unique
|
|
.B task_struct
|
|
for the child.
|
|
.SH ERRORS
|
|
.B -EAGAIN
|
|
is returned if
|
|
.B fork()
|
|
cannot allocate sufficient memory to copy the parent's
|
|
page tables and allocate a
|
|
.B task_struct
|
|
for the child.
|
|
.SH FILES
|
|
linux/kernel/fork.c
|
|
.br
|
|
/usr/include/linux/sys.h
|
|
.br
|
|
/usr/include/unistd.h
|
|
.SH SEE ALSO
|
|
exec(2)
|
|
.SH BUGS
|
|
Currently, the Linux process table is limited to 64 processes.
|