RFORK(3)
β¨ NAME β¨
rfork β manipulate process state.
okay bestie, welcome to RFORK(3) from the Library Functions Manual π
this is the page for rfork, and itβs giving βI can rearrange process state and make new processes, but read the fine print first.β π«Ά
πΈ SYNOPSIS πΈ
#include <u.h>
#include <libc.h>
int rfork(int flags)
π¦ DESCRIPTION π¦
So Rfork is a partial implementation of the Plan 9 system call, bestie. It can manipulate some process state and create new processes Γ la fork(2). It cannot be used to create shared-memory processes β thatβs Plan 9βs RFMEM flag β and if you want that functionality you use proccreate (see thread(3)). π
The flags argument to rfork picks which resources of the invoking process (the parent) are shared by the new process (the child), or initialized to their default values. flags is the logical OR of some subset of these:
π the flags menu π
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 noWaitmsg(seewait(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 (seepostnote(3)andsignal(2)). The group of a new process is by default the same as its parent, but ifRFNOTEGis set (regardless ofRFPROC), the process becomes the first in a new group, isolated from previous processes. In Plan 9, a process can callrfork(RFNOTEG)and then be sure that it will no longer receive console interrupts 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 (seeintro()) 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 processes sharing the table exit. no cap, thatβs the rule π
Now the return-value tea β: 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 zero. Process ids range from 1 to the maximum integer (int) value. Rfork will sleep, if necessary, until required process resources are available. π΄
Calling rfork(RFFDG|RFPROC) is equivalent to calling fork(2). periodt π
π SOURCE π
/src/lib9/rfork.c
π¨ DIAGNOSTICS π¨
Rfork sets errstr.
mwah π this was RFORK(3) from the Library Functions Manual, sourced at /src/lib9/rfork.c β the page doesnβt give a date, so weβre not inventing one, bestie π«Ά stay iconic β¨
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms