|
|
1.1 ! root 1: ! 2: ! 3: fork() COHERENT System Call fork() ! 4: ! 5: ! 6: ! 7: ! 8: Create a new process ! 9: ! 10: fork() ! 11: ! 12: In the COHERENT system, many processes may be active simul- ! 13: taneously. fork creates a new process; the new process is a ! 14: duplicate of the requesting process. In practice, the new ! 15: process often issues a call to execute yet another new program. ! 16: ! 17: The process that issues the fork call is termed the parent ! 18: process, and the newly forked process is termed the child ! 19: process. fork returns the process id of the newly created child ! 20: to the parent process, and returns zero to the child process. ! 21: The parent may call wait to suspend itself until the child ter- ! 22: minates. ! 23: ! 24: The following parts of the environment of a process are exactly ! 25: duplicated by a fork call: ! 26: ! 27: * Open files and their seek positions ! 28: ! 29: * Current working and root directories ! 30: ! 31: * The file creation mask ! 32: ! 33: * The values of all signals ! 34: ! 35: * The alarm clock setting ! 36: ! 37: * Code, data, and stack segments ! 38: ! 39: The system normally makes a fresh copy of the code, data, and ! 40: stack segments for the child process. One advantage of shared ! 41: text processes is that they do not need to copy the code segment. ! 42: It is write protected, and therefore may be shared. ! 43: ! 44: ***** Example ***** ! 45: ! 46: For an example of how to use this call, see pipe. ! 47: ! 48: ***** See Also ***** ! 49: ! 50: alarm(), COHERENT system calls, execl(), exit(), sh, umask(), ! 51: wait() ! 52: ! 53: ***** Diagnostics ***** ! 54: ! 55: fork returns -1 on failure, which usually involves insufficient ! 56: system resources. On successful calls, fork returns zero to the ! 57: child and the process id of the child to the parent. ! 58: ! 59: ! 60: ! 61: ! 62: ! 63: ! 64: COHERENT Lexicon Page 1 ! 65: ! 66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.