* exit before we set the pdeath signal leading to a unsupervized
* container.
*/
- ret = lxc_set_death_signal(SIGKILL);
+ ret = lxc_set_death_signal(SIGKILL, 0);
if (ret < 0) {
SYSERROR("Failed to set PR_SET_PDEATHSIG to SIGKILL");
goto out_warn_father;
goto out_warn_father;
/* set{g,u}id() clears deathsignal */
- ret = lxc_set_death_signal(SIGKILL);
+ ret = lxc_set_death_signal(SIGKILL, 0);
if (ret < 0) {
SYSERROR("Failed to set PR_SET_PDEATHSIG to SIGKILL");
goto out_warn_father;
}
if (handler->conf->monitor_signal_pdeath != SIGKILL) {
- ret = lxc_set_death_signal(handler->conf->monitor_signal_pdeath);
+ ret = lxc_set_death_signal(handler->conf->monitor_signal_pdeath, 0);
if (ret < 0) {
SYSERROR("Failed to set PR_SET_PDEATHSIG to %d",
handler->conf->monitor_signal_pdeath);
return n;
}
-int lxc_set_death_signal(int signal)
+int lxc_set_death_signal(int signal, pid_t parent)
{
int ret;
pid_t ppid;
/* Check whether we have been orphaned. */
ppid = (pid_t)syscall(SYS_getppid);
- if (ppid == 1) {
- pid_t self;
-
- self = lxc_raw_getpid();
- ret = kill(self, SIGKILL);
+ if (ppid != parent) {
+ ret = raise(SIGKILL);
if (ret < 0)
return -1;
}
}
/* 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 recursive_destroy(char *dirname);
extern int lxc_setup_keyring(void);