Request SIGTERM be sent to forked child processes if the parent process dies.
Signed-off-by: Carl Wallen <[email protected]> --- helper/linux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helper/linux.c b/helper/linux.c index 3d3b6b8..3d5da18 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; -- 2.1.4 _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
