

fork()                 COHERENT System Call                fork()




Create a new process

fork()

In  the COHERENT  system,  many processes  may  be active  simul-
taneously.   fork creates  a new  process; the  new process  is a
duplicate  of  the  requesting  process.   In practice,  the  new
process often issues a call to execute yet another new program.

The  process  that issues  the  fork call  is  termed the  parent
process,  and  the  newly  forked  process  is termed  the  child
process.  fork returns the  process id of the newly created child
to the  parent process,  and returns  zero to the  child process.
The parent  may call wait to suspend itself  until the child ter-
minates.

The following  parts of the environment of  a process are exactly
duplicated by a fork call:

*  Open files and their seek positions

*  Current working and root directories

*  The file creation mask

*  The values of all signals

*  The alarm clock setting

*  Code, data, and stack segments

The system  normally makes  a fresh copy  of the code,  data, and
stack segments  for the child  process.  One advantage  of shared
text processes is that they do not need to copy the code segment.
It is write protected, and therefore may be shared.

***** Example *****

For an example of how to use this call, see pipe.

***** See Also *****

alarm(),  COHERENT system  calls, execl(),  exit(),  sh, umask(),
wait()

***** Diagnostics *****

fork returns  -1 on failure, which  usually involves insufficient
system resources.  On  successful calls, fork returns zero to the
child and the process id of the child to the parent.






COHERENT Lexicon                                           Page 1


