From 2a16e8d4c1d9e57ebf97d1eae1865c62fb3fc572 Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Tue, 18 Feb 2020 10:09:29 +0100 Subject: [PATCH] Kill child if parent dies (#2544) --- cli/threadexecutor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 26d05d971..ad834045e 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -36,6 +36,9 @@ #include #endif #ifdef THREADING_MODEL_FORK +#if defined(__linux__) +#include +#endif #include #include #include @@ -204,6 +207,9 @@ unsigned int ThreadExecutor::check() std::cerr << "#### ThreadExecutor::check, Failed to create child process: "<< std::strerror(errno) << std::endl; std::exit(EXIT_FAILURE); } else if (pid == 0) { +#if defined(__linux__) + prctl(PR_SET_PDEATHSIG, SIGHUP); +#endif close(pipes[0]); mWpipe = pipes[1];