diff options
author | dzwdz | 2024-05-25 21:43:13 +0200 |
---|---|---|
committer | dzwdz | 2024-05-25 21:43:13 +0200 |
commit | 88726ea9830c7213a7d9c1965eba97d3987b87d5 (patch) | |
tree | 40f40648c604704e40d865e97564afe653f85115 /man/fork.2 | |
parent | 5b21be296ea2da40759a5ac0db9ab3eda686c744 (diff) |
man: start writing manpages
Diffstat (limited to 'man/fork.2')
-rw-r--r-- | man/fork.2 | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/man/fork.2 b/man/fork.2 new file mode 100644 index 0000000..97b0f8a --- /dev/null +++ b/man/fork.2 @@ -0,0 +1,71 @@ +.Dd May 20, 2024 +.Dt FORK 2 +.Os Camellia +.Sh NAME +.Nm fork +.Nd copy the current process +.Sh SYNOPSIS +.In camellia/flags.h +.In camellia/syscalls.h +.In camellia/types.h +.Ft long +.Fo _sys_fork +.Fa "int flags" +.Fa "hid_t *fs_front" +.Fc +.Sh DESCRIPTION +.Nm +creates a copy of the current process and schedules it for execution. +.Pp +.Fa flags +is a bitmask, with the following options: +.Bl -tag -width FORK_SHAREHANDLE +.It Dv FORK_SHAREMEM +Share the parent's pagetable with the child. +If this flag is not passed, +the entire address space of the parent is copied (no CoW yet). +Any new memory allocations will be reflected in both processes. +.It Dv FORK_SHAREHANDLE +Share the parent's handle set with the child. +The effects of +.Xr open 2 , +.Xr close 2 , +etc. will be reflected in both processes. +.It Dv FORK_NOREAP +Ignore the child in future +.Xr wait2 2 +calls. +It will be automatically reaped on death, +without waiting for the parent to take action. +.It Dv FORK_NEWFS +Make the child responsible for a new filesystem, +and put its corresponding handle in +.Fa *fs_front . +The handle can then be passed to +.Xr mount 2 . +.El +.Pp +.Fa fs_front +is ignored, +unless +.Dv FORK_NEWFS +is specified. +It should be +.Dv NULL +otherwise. +.Sh RETURN VALUES +When successful, +.Nm +returns 0 in the child, +and the child's PID in the parent. +When not succesful, it returns one of the following (negated) errors: +.Bl -tag -width EMFILE +.It Er EMFILE +.Dv FORK_NEWFS +was specified and there's no handles left in the parent. +.El +.Sh SEE ALSO +.Xr exit 2 , +.Xr getpid 2 , +.Xr getprocfs 2 , +.Xr wait2 2 |