From 8bc303995ada898102d95f7315693063d57ff2e1 Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Fri, 7 Oct 2011 23:37:42 +0000 Subject: [PATCH] Ecore Exe: add flag to send SIGTERM when parent die Add a new ecore exe flag, ECORE_EXE_TERM_WITH_PARENT, that will operate on child process, sending a SIGTERM when parent process dies. SVN revision: 63915 --- legacy/ecore/src/lib/ecore/Ecore.h | 3 ++- legacy/ecore/src/lib/ecore/ecore_exe.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/legacy/ecore/src/lib/ecore/Ecore.h b/legacy/ecore/src/lib/ecore/Ecore.h index b2b2a83197..c6b439e57d 100644 --- a/legacy/ecore/src/lib/ecore/Ecore.h +++ b/legacy/ecore/src/lib/ecore/Ecore.h @@ -654,7 +654,8 @@ extern "C" { ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */ ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */ ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */ - ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */ + ECORE_EXE_NOT_LEADER = 256, /**< Do not use setsid() to have the executed process be its own session leader */ + ECORE_EXE_TERM_WITH_PARENT = 512 /**< Makes child receive SIGTERM when parent dies. */ }; typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags; diff --git a/legacy/ecore/src/lib/ecore/ecore_exe.c b/legacy/ecore/src/lib/ecore/ecore_exe.c index 07407ef162..568a35cdb6 100644 --- a/legacy/ecore/src/lib/ecore/ecore_exe.c +++ b/legacy/ecore/src/lib/ecore/ecore_exe.c @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef HAVE_SYS_WAIT_H # include @@ -1509,6 +1510,11 @@ _ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags) } } + if ((flags & ECORE_EXE_TERM_WITH_PARENT)) + { + prctl(PR_SET_PDEATHSIG, SIGTERM); + } + if (!(flags & ECORE_EXE_NOT_LEADER)) setsid(); if ((flags & ECORE_EXE_USE_SH)) {