From ea5ebb4a12b0dc9303f372986cf706de55975532 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 27 Oct 2020 05:24:44 -0700 Subject: [PATCH] ircd::exec: Set PDEATHSIG in the child for crash action. --- configure.ac | 1 + ircd/exec.cc | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/configure.ac b/configure.ac index 8bb9fd191..4a96d792d 100644 --- a/configure.ac +++ b/configure.ac @@ -1052,6 +1052,7 @@ RB_CHK_SYSHEADER(sys/sysinfo.h, [SYS_SYSINFO_H]) RB_CHK_SYSHEADER(sys/eventfd.h, [SYS_EVENTFD_H]) RB_CHK_SYSHEADER(sys/inotify.h, [SYS_INOTIFY_H]) RB_CHK_SYSHEADER(sys/sysmacros.h, [SYS_SYSMACROS_H]) +RB_CHK_SYSHEADER(sys/prctl.h, [SYS_PRCTL_H]) RB_CHK_SYSHEADER(linux/aio_abi.h, [LINUX_AIO_ABI_H]) RB_CHK_SYSHEADER(linux/magic.h, [LINUX_MAGIC_H]) RB_CHK_SYSHEADER(linux/perf_event.h, [LINUX_PERF_EVENT_H]) diff --git a/ircd/exec.cc b/ircd/exec.cc index 806d9436d..7575b2bf6 100644 --- a/ircd/exec.cc +++ b/ircd/exec.cc @@ -8,6 +8,7 @@ // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. +#include #include @@ -339,6 +340,11 @@ const noexcept }; #endif + // Set the parent death signal in case of a crash so we won't go zombie. + #if defined(HAVE_SYS_PRCTL_H) + sys::call(prctl, PR_SET_PDEATHSIG, SIGTERM); + #endif + // Ignore SIGINT/SIGQUIT that way the administrator striking ctrl-c or // ctrl-\ at the console doesn't terminate the child. #if defined(HAVE_SIGNAL_H)