Debian Codegraph @

upstream/debian-unstable/man2/PR_SET_CHILD_SUBREAPER.2const

raw
1 .\" Copyright 2012-2015, Michael Kerrisk <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH PR_SET_CHILD_SUBREAPER 2const 2026-02-08 "Linux man-pages 6.18"
7 .SH NAME
8 PR_SET_CHILD_SUBREAPER
9 \-
10 set/unset the "child subreaper" attribute of the calling process
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */"
17 .B #include <sys/prctl.h>
18 .P
19 .BI "int prctl(PR_SET_CHILD_SUBREAPER, long " set );
20 .fi
21 .SH DESCRIPTION
22 If
23 .I set
24 is nonzero,
25 set the "child subreaper" attribute of the calling process;
26 if
27 .I set
28 is zero, unset the attribute.
29 .P
30 A subreaper fulfills the role of
31 .BR init (1)
32 for its descendant processes.
33 When a process becomes orphaned
34 (i.e., its immediate parent terminates),
35 then that process will be reparented to
36 the nearest still living ancestor subreaper.
37 Subsequently, calls to
38 .BR getppid (2)
39 in the orphaned process will now return the PID of the subreaper process,
40 and when the orphan terminates, it is the subreaper process that
41 will receive a
42 .B SIGCHLD
43 signal and will be able to
44 .BR wait (2)
45 on the process to discover its termination status.
46 .P
47 The setting of the "child subreaper" attribute
48 is not inherited by children created by
49 .BR fork (2)
50 and
51 .BR clone (2).
52 The setting is preserved across
53 .BR execve (2).
54 .P
55 Establishing a subreaper process is useful in session management frameworks
56 where a hierarchical group of processes is managed by a subreaper process
57 that needs to be informed when one of the processes\[em]for example,
58 a double-forked daemon\[em]terminates
59 (perhaps so that it can restart that process).
60 Some
61 .BR init (1)
62 frameworks (e.g.,
63 .BR systemd (1))
64 employ a subreaper process for similar reasons.
65 .SH RETURN VALUE
66 On success,
67 0 is returned.
68 On error, \-1 is returned, and
69 .I errno
70 is set to indicate the error.
71 .SH STANDARDS
72 Linux.
73 .SH HISTORY
74 Linux 3.4.
75 .\" commit ebec18a6d3aa1e7d84aab16225e87fd25170ec2b
76 .SH SEE ALSO
77 .BR prctl (2),
78 .BR PR_GET_CHILD_SUBREAPER (2const)