RFORK(3)                                                 RFORK(3)

     NAME
          rfork - manipulate process state

     SYNOPSIS
          #include <u.h>
          #include <libc.h>

          int rfork(int flags)

     DESCRIPTION
          Rfork is a partial implementation of the Plan 9 system call.
          It can be used to manipulate some process state and to cre-
          ate new processes a la fork(2). It cannot be used to create
          shared-memory processes (Plan 9's RFMEM flag); for that
          functionality use proccreate (see thread(3)).

          The flags argument to rfork selects which resources of the
          invoking process (parent) are shared by the new process
          (child) or initialized to their default values.  Flags is
          the logical OR of some subset of

          RFPROC    If set a new process is created; otherwise changes
                    affect the current process.
          RFNOWAIT  If set, the child process will be dissociated from
                    the parent. Upon exit the child will leave no
                    Waitmsg (see wait(3)) for the parent to collect.
          RFNOTEG   Each process is a member of a group of processes
                    that all receive notes when a note is sent to the
                    group (see postnote(3) and signal(2)). The group
                    of a new process is by default the same as its
                    parent, but if RFNOTEG is set (regardless of
                    RFPROC), the process becomes the first in a new
                    group, isolated from previous processes.  In Plan
                    9, a process can call rfork(RFNOTEG) and then be
                    sure that it will no longer receive console inter-
                    rupts or other notes.  Unix job-control shells put
                    each command in its own process group and then
                    relay notes to the current foreground command,
                    making the idiom less useful.
          RFFDG     If set, the invoker's file descriptor table (see
                    intro()) is copied; otherwise the two processes
                    share a single table.

          File descriptors in a shared file descriptor table are kept
          open until either they are explicitly closed or all pro-
          cesses sharing the table exit.

          If RFPROC is set, the value returned in the parent process
          is the process id of the child process; the value returned
          in the child is zero.  Without RFPROC, the return value is

     Page 1                       Plan 9            (printed 11/18/24)

     RFORK(3)                                                 RFORK(3)

          zero.  Process ids range from 1 to the maximum integer (int)
          value.  Rfork will sleep, if necessary, until required pro-
          cess resources are available.

          Calling rfork(RFFDG|RFPROC) is equivalent to calling
          fork(2).

     SOURCE
          /usr/local/plan9/src/lib9/rfork.c

     DIAGNOSTICS
          Rfork sets errstr.

     Page 2                       Plan 9            (printed 11/18/24)