ecore_exe/efl_exe - implement exit with parent on bsds with procctl

This commit is contained in:
Carsten Haitzler 2020-01-15 02:35:11 +00:00
parent 77db0820e3
commit 72a8a2ce40
3 changed files with 19 additions and 2 deletions

View File

@ -97,6 +97,7 @@ function_checks = [
['mmap', ['sys/mman.h']],
['mtrace', ['mcheck.h']],
['prctl', ['sys/prctl.h']],
['procctl', ['sys/procctl.h']],
['realpath', ['stdlib.h']],
['setxattr', ['sys/types.h', 'sys/xattr.h']],
['siglongjmp', ['setjmp.h']],

View File

@ -16,6 +16,8 @@
#ifdef HAVE_PRCTL
# include <sys/prctl.h>
#elif defined(HAVE_PROCCTL)
# include <sys/procctl.h>
#endif
#ifdef HAVE_SYS_WAIT_H
@ -1000,6 +1002,12 @@ _ecore_exe_exec_it(const char *exe_cmd,
{
prctl(PR_SET_PDEATHSIG, SIGTERM);
}
#elif defined(HAVE_PROCCTL)
if ((flags & ECORE_EXE_TERM_WITH_PARENT))
{
int sig = SIGTERM;
procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &sig);
}
#endif
if (!(flags & ECORE_EXE_NOT_LEADER)) setsid();

View File

@ -25,8 +25,10 @@
# include <sys/socket.h>
# ifdef HAVE_PRCTL
# include <sys/prctl.h>
# elif defined(HAVE_PROCCTL)
# include <sys/procctl.h>
# endif
# ifdef HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
# endif
# ifndef HAVE_CLEARENV
@ -150,7 +152,13 @@ _exec(const char *cmd, Efl_Exe_Flags flags, Efl_Task_Flags task_flags)
# ifdef HAVE_PRCTL
if (task_flags & EFL_TASK_FLAGS_EXIT_WITH_PARENT)
prctl(PR_SET_PDEATHSIG, SIGTERM);
# endif
#elif defined(HAVE_PROCCTL)
if (task_flags & EFL_TASK_FLAGS_EXIT_WITH_PARENT)
{
int sig = SIGTERM;
procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &sig);
}
#endif
if (flags & EFL_EXE_FLAGS_GROUP_LEADER) setsid();
if (use_sh) // We have to use a shell to run this.