utils: fix lxc_set_death_signal()

parent 40671e8e
...@@ -1052,7 +1052,7 @@ static int do_start(void *data) ...@@ -1052,7 +1052,7 @@ static int do_start(void *data)
* exit before we set the pdeath signal leading to a unsupervized * exit before we set the pdeath signal leading to a unsupervized
* container. * container.
*/ */
ret = lxc_set_death_signal(SIGKILL); ret = lxc_set_death_signal(SIGKILL, 0);
if (ret < 0) { if (ret < 0) {
SYSERROR("Failed to set PR_SET_PDEATHSIG to SIGKILL"); SYSERROR("Failed to set PR_SET_PDEATHSIG to SIGKILL");
goto out_warn_father; goto out_warn_father;
...@@ -1130,7 +1130,7 @@ static int do_start(void *data) ...@@ -1130,7 +1130,7 @@ static int do_start(void *data)
goto out_warn_father; goto out_warn_father;
/* set{g,u}id() clears deathsignal */ /* set{g,u}id() clears deathsignal */
ret = lxc_set_death_signal(SIGKILL); ret = lxc_set_death_signal(SIGKILL, 0);
if (ret < 0) { if (ret < 0) {
SYSERROR("Failed to set PR_SET_PDEATHSIG to SIGKILL"); SYSERROR("Failed to set PR_SET_PDEATHSIG to SIGKILL");
goto out_warn_father; goto out_warn_father;
......
...@@ -1645,7 +1645,7 @@ uint64_t lxc_find_next_power2(uint64_t n) ...@@ -1645,7 +1645,7 @@ uint64_t lxc_find_next_power2(uint64_t n)
return n; return n;
} }
int lxc_set_death_signal(int signal) int lxc_set_death_signal(int signal, pid_t parent)
{ {
int ret; int ret;
pid_t ppid; pid_t ppid;
...@@ -1655,11 +1655,8 @@ int lxc_set_death_signal(int signal) ...@@ -1655,11 +1655,8 @@ int lxc_set_death_signal(int signal)
/* Check whether we have been orphaned. */ /* Check whether we have been orphaned. */
ppid = (pid_t)syscall(SYS_getppid); ppid = (pid_t)syscall(SYS_getppid);
if (ppid == 1) { if (ppid != parent) {
pid_t self; ret = raise(SIGKILL);
self = lxc_raw_getpid();
ret = kill(self, SIGKILL);
if (ret < 0) if (ret < 0)
return -1; return -1;
} }
......
...@@ -433,7 +433,7 @@ static inline pid_t lxc_raw_gettid(void) ...@@ -433,7 +433,7 @@ static inline pid_t lxc_raw_gettid(void)
} }
/* Set a signal the child process will receive after the parent has died. */ /* Set a signal the child process will receive after the parent has died. */
extern int lxc_set_death_signal(int signal); extern int lxc_set_death_signal(int signal, pid_t parent);
extern int fd_cloexec(int fd, bool cloexec); extern int fd_cloexec(int fd, bool cloexec);
extern int recursive_destroy(char *dirname); extern int recursive_destroy(char *dirname);
extern int lxc_setup_keyring(void); extern int lxc_setup_keyring(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment