pdeathsigexec cmd ...
pdeathsigexec: signal process when parent exits
Subprocesses orphaned by a parent process's exit are typically reparented
to init (PID 1) and continue running. pdeathsigexec
ensures a process
receives a signal upon its parent's termination.
The "signal on parent termination" behaviour applies to the executed process only and not descendents (prctl(2)):
The parent-death signal setting is cleared for the child of a fork(2). It is also (since Linux 2.4.36 / 2.6.23) cleared when executing a set-user-ID or set-group-ID binary, or a binary that has associated capabilities (see capabilities(7)); otherwise, this value is preserved across execve(2).
The behaviour can be set for related, dynamically linked processes in
a supervision tree by using a LD_PRELOAD
library (see EXAMPLES
).
$ sh -c "sleep inf" &
[1] 25880
$ kill -9 25880
$ pgrep -fa sleep
25882 sleep inf
$ sh -c "pdeathsigexec sleep inf" &
[1] 25926
$ kill -9 25926
$ pgrep -fa sleep
<no output>
$ LD_PRELOAD=libpdeathsigexec.so sh -c 'sh -c "sleep inf" & sleep inf' &
[1] 25987
$ kill -9 25987
$ pgrep -fa sleep
<no output>
make
#### static executable using musl
## sudo apt install musl-dev musl-tools
./musl-make
-s/--signal
: set the termination signal (default 9
(SIGKILL))
PDEATHSIGEXEC_SIGNAL
: set the termination signal (default 9
(SIGKILL))