| 
      rfork - control new processes
      #include <sys/param.h>
     #include <unistd.h>
     int
     rfork(int flags);
     The fork functions (fork(2), vfork(2), and  rfork())  create
new processes.
     The  new  process  (child  process)  is an exact copy of the
calling process
     (parent process), except as outlined in the  fork(2)  manual
page.  rfork()
     can  be  used to manipulate the resources of the parent process and the
     child  process.   Operations  currently  supported   include
whether to copy or
     share  the  file descriptor table between the two processes,
whether to
     share the address  space,  and  whether  the  parent  should
wait(2) for the
     child process to _exit(2).  rfork() takes a single argument,
flags, which
     controls which of these  resources  should  be  manipulated.
They are defined
  in  the header file <sys/param.h> and are the logical
OR of one or
     more of the following:
     RFNAMEG   New Plan 9 `name space'.  This is a Plan 9 specific flag, and
               not implemented.
     RFENVG    Copy Plan 9 `env space'.  This is a Plan 9 specific flag, and
               not implemented.
     RFFDG     Copy the parent's file descriptor table.  If  this
flag is unset,
  the parent and child will share the parent's
file descriptor
 table.  May not be used  in  conjunction  with
RFCFDG.
     RFNOTEG    Create new Plan 9 `note group'.  This is a Plan 9
specific
               flag, and not implemented.
     RFPROC    Create a new process.  The current  implementation
requires this
               flag to always be set.
     RFMEM      The  kernel  forces sharing of the entire address
space.  The
               child will then inherit all  the  shared  segments
the parent process
  owns.   Subsequent  forks by the parent will
then propagate
               the shared data and bss between children.
     RFNOWAIT  Parent need not wait(2) on child.
     RFCNAMEG  Zero Plan 9 `name space'.  This is a Plan  9  specific flag, and
               not implemented.
     RFCENVG   Zero Plan 9 `env space'.  This is a Plan 9 specific flag, and
               not implemented.
     RFCFDG    Zero the child's file descriptor table (i.e. start
with a blank
               file  descriptor  table).  May not be used in conjunction with
               RFFDG.
     The parent process returns the process ID (PID) of the child
process.
     The child process returns 0.  The range of the process ID is
defined in
     <sys/proc.h> and is currently between 1  and  32766,  inclusive.
     fork()  can  be  implemented  as  a  call  to  rfork() using
"RFFDG|RFPROC", but
     isn't for backwards compatibility.  If a  process  has  file
descriptor
     table sharing active, setuid or setgid programs will not execve(2) with
     extra privileges.
     rfork() will fail and no child process will be created if:
     [ENOMEM]      Cannot allocate memory.  The new process image
required
                   more  memory  than was allowed by the hardware
or by systemimposed
 memory management constraints.  A lack
of swap
                   space  is  normally temporary; however, a lack
of core is
                   not.  Soft limits may be  increased  to  their
corresponding
                   hard limits.
     [EINVAL]       Invalid  argument.  Some invalid argument was
supplied.
     [EAGAIN]      Resource temporarily unavailable.  The systemimposed limit
                   on  the total number of processes under execution would be
                   exceeded.  This limit is  configuration-dependent.
     [EAGAIN]      Resource temporarily unavailable.  The systemimposed limit
                   MAXUPRC on the total number of processes under
execution by
                   a  single  user would be exceeded.  MAXUPRC is
currently defined
 in <sys/param.h> as CHILD_MAX, which  is
currently defined
 as 80 in <sys/limits.h>.
     _exit(2), execve(2), fork(2), intro(2), vfork(2)
     The rfork() function first appeared in Plan 9.
OpenBSD      3.6                           June      17,     2003
[ Back ] |