|
|
1.1 ! root 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 ! 10: fork \- create a new process ! 11: .SH SYNOPSIS ! 12: .ft B ! 13: pid = fork() ! 14: .br ! 15: int pid; ! 16: .ft R ! 17: .SH DESCRIPTION ! 18: .I Fork ! 19: causes creation of a new process. ! 20: The new process (child process) is an exact copy of the ! 21: calling process except for the following: ! 22: .in +5n ! 23: .sp ! 24: The child process has a unique process ID. ! 25: .sp ! 26: The child process has a different parent process ID (i.e., ! 27: the process ID of the parent process). ! 28: .sp ! 29: The child process has its own copy of the parent's descriptors. ! 30: These descriptors reference the same underlying objects, so that, ! 31: for instance, file pointers in file objects are shared between ! 32: the child and the parent, so that an ! 33: .IR lseek (2) ! 34: on a descriptor in the child process can affect a subsequent ! 35: .I read ! 36: or ! 37: .I write ! 38: by the parent. ! 39: This descriptor copying is also used by the shell to ! 40: establish standard input and output for newly created processes ! 41: as well as to set up pipes. ! 42: .sp ! 43: The child processes resource utilizations are set to 0; ! 44: see ! 45: .IR setrlimit (2). ! 46: .SH "RETURN VALUE ! 47: Upon successful completion, \fIfork\fP returns a value ! 48: of 0 to the child process and returns the process ID of the child ! 49: process to the parent process. Otherwise, a value of \-1 is returned ! 50: to the parent process, no child process is created, and the global ! 51: variable \fIerrno\fP is set to indicate the error. ! 52: .SH ERRORS ! 53: .I Fork ! 54: will fail and no child process will be created if one or more of the ! 55: following are true: ! 56: .TP 15 ! 57: [EAGAIN] ! 58: The system-imposed limit on the total ! 59: number of processes under execution would be exceeded. ! 60: This limit is configuration-dependent. ! 61: .TP 15 ! 62: [EAGAIN] ! 63: The system-imposed limit MAXUPRC (\fI<sys/param.h>) \fRon the total number of ! 64: processes under execution by a single user would be exceeded. ! 65: .TP 15 ! 66: [ENOMEM] ! 67: There is insufficient swap space for the new process. ! 68: .SH "SEE ALSO" ! 69: execve(2), wait(2)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.