FreeBSD Manual Pages
RFORK(2) OpenBSD Programmer's Manual RFORK(2) NAME rfork - control new processes SYNOPSIS #include <sys/param.h> #include <unistd.h> int rfork(int flags); DESCRIPTION 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 de- fined 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 un- set, the parent and child will share the parent's file descrip- tor 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 pro- cess owns. Subsequent forks by the parent will then propagate the shared data and bss between children. The stack segment is always split. 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 (ie. start with a blank file descriptor table). May not be used in conjunction with RFFDG. RETURN VALUES 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. ERRORS 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 system- imposed 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 system-imposed limit on the total number of processes under execution would be exceeded. This limit is configuration-dependent. [EAGAIN] Resource temporarily unavailable. The system-imposed limit MAXUPRC on the total number of processes under execution by a single user would be exceeded. MAXUPRC is currently de- fined in <sys/param.h> as CHILD_MAX, which is currently de- fined as 80 in <sys/limits.h>. SEE ALSO _exit(2), execve(2), fork(2), intro(2), vfork(2) HISTORY The rfork() function first appeared in Plan 9. OpenBSD 3.4 June 17, 2003 2
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | SEE ALSO | HISTORY
Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=rfork&sektion=2&manpath=OpenBSD+3.4>