COHERENT manpages

This page displays the COHERENT manpage for fork() [Create a new process].

List of available manpages
Index


fork() -- System Call (libc)

Create a new process
#include <unistd.h>
fork()

In  the  COHERENT  system, many  processes  may  be active  simultaneously.
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 terminates.

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 examples of how to use this call, see msgget(), pipe(), and signal().

See Also

alarm(),
execl(),
exit(),
libc,
sh,
umask(),
unistd.h,
wait()
POSIX Standard, §3.1.1

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.