.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