aboutsummaryrefslogtreecommitdiff
path: root/helper
diff options
context:
space:
mode:
authorCarl Wallen <carl.wallen@nokia.com>2015-10-30 15:16:05 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-11-05 10:34:07 +0300
commit3d0dafc1dc72dab028db1b06f183339e7d578d5b (patch)
treee0279ff50d6efd6057a6a3d988ca820db510e831 /helper
parent3419b057beb82fd556c03e1af06cfb65e70ed9dd (diff)
helper: linux: request SIGTERM if parent process dies
Request SIGTERM be sent to forked child processes if the parent process dies. Signed-off-by: Carl Wallen <carl.wallen@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'helper')
-rw-r--r--helper/linux.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/helper/linux.c b/helper/linux.c
index 3d3b6b86a..3d5da184e 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/prctl.h>
#include <stdlib.h>
#include <string.h>
@@ -167,6 +168,13 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
}
/* Child process */
+
+ /* Request SIGTERM if parent dies */
+ prctl(PR_SET_PDEATHSIG, SIGTERM);
+ /* Parent died already? */
+ if (getppid() == 1)
+ kill(getpid(), SIGTERM);
+
if (sched_setaffinity(0, sizeof(cpu_set_t), &proc_mask.set)) {
ODPH_ERR("sched_setaffinity() failed\n");
return -2;