File: PR_SET_PDEATHSIG.2const

package info (click to toggle)
manpages 6.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,808 kB
  • sloc: sh: 503; python: 222; perl: 165; makefile: 27; lisp: 22
file content (100 lines) | stat: -rw-r--r-- 2,816 bytes parent folder | download
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
.\" Copyright 1998, Andries Brouwer <aeb@cwi.nl>
.\" Copyright 2002, 2006, 2008, 2012, 2013, 2015, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Copyright 2024, Alejandro Colomar <alx@kernel.org>
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH PR_SET_PDEATHSIG 2const 2024-06-02 "Linux man-pages (unreleased)"
.SH NAME
PR_SET_PDEATHSIG
\-
set the parent-death signal of the calling process
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.BR "#include <linux/prctl.h>" "  /* Definition of " PR_* " constants */"
.B #include <sys/prctl.h>
.P
.BI "int prctl(PR_SET_PDEATHSIG, long " sig );
.fi
.SH DESCRIPTION
Set the parent-death signal
of the calling process to
.I sig
(either a signal value
in the range
.RB [ 1 ,
.IR NSIG\~\-\~1 ],
or
.B 0
to clear).
This is the signal that the calling process will get when its
parent dies.
.P
The parent-death signal is sent
upon subsequent termination of the parent thread
and also upon termination of each subreaper process
(see
.BR PR_SET_CHILD_SUBREAPER (2const))
to which the caller is subsequently reparented.
If the parent thread and all ancestor subreapers have already terminated
by the time of the
.B PR_SET_PDEATHSIG
operation, then no parent-death signal is sent to the caller.
.P
The parent-death signal is process-directed (see
.BR signal (7))
and, if the child installs a handler using the
.BR sigaction (2)
.B SA_SIGINFO
flag, the
.I si_pid
field of the
.I siginfo_t
argument of the handler contains the PID of the terminating parent process.
.P
The parent-death signal setting is cleared for the child of a
.BR fork (2).
It is also
(since Linux 2.4.36 / 2.6.23)
.\" commit d2d56c5f51028cb9f3d800882eb6f4cbd3f9099f
cleared when executing a set-user-ID or set-group-ID binary,
or a binary that has associated capabilities (see
.BR capabilities (7));
otherwise, this value is preserved across
.BR execve (2).
The parent-death signal setting is also cleared upon changes to
any of the following thread credentials:
.\" FIXME capability changes can also trigger this; see
.\" kernel/cred.c::commit_creds in the Linux 5.6 source.
effective user ID, effective group ID, filesystem user ID,
or filesystem group ID.
.SH RETURN VALUE
On success,
0 is returned.
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EINVAL
.I sig
is not a valid signal number.
.SH STANDARDS
Linux.
.SH HISTORY
Linux 2.1.57.
.SH CAVEATS
.\" https://bugzilla.kernel.org/show_bug.cgi?id=43300
The "parent" in this case is considered to be the
.I thread
that created this process.
In other words, the signal will be sent when that thread terminates
(via, for example,
.BR pthread_exit (3)),
rather than after all of the threads in the parent process terminate.
.SH SEE ALSO
.BR prctl (2),
.BR PR_GET_PDEATHSIG (2const)