mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
timeout: ensure we terminate command upon abnormal exit
* src/timeout.c (main): Use PR_SET_PDEATHSIG to ensure the child is terminated even if the parent terminates abnormally. * tests/timeout/timeout-group.sh: Add a case to ensure sending SIGKILL results in the termination of the monitored command. * NEWS: Mention the improvement.
This commit is contained in:
1 parent
d1d311e7a2
commit
fc5c7b2e47
3 files changed
+30
-1
No files matched your search
@@ -592,6 +592,14 @@ main (int argc, char **argv)
|
||||
}
|
||||
else if (monitored_pid == 0) /* child */
|
||||
{
|
||||
#if HAVE_PRCTL
|
||||
/* Add protection if the parent dies without signalling child. */
|
||||
prctl (PR_SET_PDEATHSIG, term_signal);
|
||||
#endif
|
||||
/* If we're already reparented to init, don't proceed. */
|
||||
if (getppid () == 1)
|
||||
return EXIT_CANCELED;
|
||||
|
||||
/* Restore signal mask for child. */
|
||||
if (sigprocmask (SIG_SETMASK, &orig_set, nullptr) != 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user