summaryrefslogtreecommitdiff
path: root/man/fork.2
blob: 97b0f8a5b12b665a2e29a485b460429988127b79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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