.th K_fork II 4/21/86
.sh NAME
K_fork - create copy of current process
.sh "MODULA SYNOPSIS"
.nh
.na
 VAR own: seid;
.br
 VAR other: seid;
.br
 VAR stat: K_err_num;
.br
 . . .
.br
 stat := NK_fork(own, other);
.br
.hy
.ad
.sp
.sh "C SYNOPSIS"
.nh
.na
 seid own;
.br
 seid other;
.br
 int stat;
.br
 . . .
.br
 stat = K_fork (&own, &other);
.br
.hy
.ad
.sh DESCRIPTION
The K_fork primitive creates a process.  The new process is remembered
as a child of the caller (parent).  The child is an exact duplicate of
the parent.  The process id of the parent is returned to the child.
The process id of the child is returned to the parent.  The program
counter of the parent is not adjusted as it is in standard UNIX.  The
returned process id will be sufficient to distinguish parent and child.
The type independent information of the child process is identical to
the type independent information of the parent process.
.sp
The non-sharable segments of the process are copied into new segment
instances for the child.  The reference counts of sharable segments are
incremented.  The process local segment names are the same in both the
parent and child, although in the case of non-sharable segments they
refer to a different segment instance (and therefore, a different
segment SEID) for the child than for the parent.
.sp
The child inherits the open objects of the parent.  That is, each
object that is open in the parent is opened in the child, and has the
same local open object descriptor.  The open counts of the open objects
so inherited are incremented to reflect the fact that another process
(the child) has them open.  If the parent has an object open for
exclusive use, the K_fork call fails, preventing two processes from
having simultaneous access to the same exclusive use object.
.sp
An error is returned in stat if the pool of available processes has
been exhausted.
.sh EXCEPTIONS
.lp 22 15
XexFile	Process has file(s) open for exclusive use.
.lp 22 15
XncnDo	System Resource exhaustion. Too many segments 
in system.
.lp 22 15
XnoProc	System Resource Exhaustion. Too many processes 
in system.
.i0
.sh "SEE ALSO"
K_invoke(II),
K_spawn(II),
seid(IIa),
tii_struct(IIa)
