source: trunk/minix/man/man2/fork.2@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 2.1 KB
Line 
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.
4.\"
5.\" @(#)fork.2 6.4 (Berkeley) 5/22/86
6.\"
7.TH FORK 2 "May 22, 1986"
8.UC
9.SH NAME
10fork \- create a new process
11.SH SYNOPSIS
12.nf
13.ft B
14#include <sys/types.h>
15#include <unistd.h>
16
17pid_t fork(void)
18.ft R
19.fi
20.SH DESCRIPTION
21.de SP
22.if t .sp 0.4
23.if n .sp
24..
25.B Fork
26causes creation of a new process.
27The new process (child process) is an exact copy of the
28calling process except for the following:
29.RS
30.SP
31The child process has a unique process ID.
32.SP
33The child process has a different parent process ID (i.e.,
34the process ID of the parent process).
35.SP
36The child process has its own copy of the parent's descriptors.
37These descriptors reference the same underlying objects, so that,
38for instance, file pointers in file objects are shared between
39the child and the parent, so that an
40.BR lseek (2)
41on a descriptor in the child process can affect a subsequent
42.B read
43or
44.B write
45by the parent.
46This descriptor copying is also used by the shell to
47establish standard input and output for newly created processes
48as well as to set up pipes.
49.SP
50The child starts with no pending signals and an inactive alarm timer.
51.RE
52.SH "RETURN VALUE
53Upon successful completion, \fBfork\fP returns a value
54of 0 to the child process and returns the process ID of the child
55process to the parent process. Otherwise, a value of \-1 is returned
56to the parent process, no child process is created, and the global
57variable \fBerrno\fP is set to indicate the error.
58.SH ERRORS
59.B Fork
60will fail and no child process will be created if one or more of the
61following are true:
62.TP 15
63[EAGAIN]
64The system-imposed limit on the total
65number of processes under execution would be exceeded.
66This limit is configuration-dependent.
67(The kernel variable NR_PROCS in <minix/config.h> (Minix), or
68<minix/const.h> (Minix-vmd).)
69.TP 15
70[ENOMEM]
71There is insufficient (virtual) memory for the new process.
72.SH "SEE ALSO"
73.BR execve (2),
74.BR wait (2).
Note: See TracBrowser for help on using the repository browser.