close prctl window

If the pdeath signal is set after the synchro we have a window where
the parent exits with the pdeath signal not set.

In order to avoid that, we have to move the prctl before the synchro with
the parent so if the parent exits before we can set the pdeath signal, the
synchro will fail in any case and the container startup will be aborted.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Daniel Lezcano 2010-07-06 21:26:31 +02:00
parent cba56779c8
commit 743ecd2efb

View File

@ -422,6 +422,17 @@ static int do_start(void *data)
return -1;
}
/* This prctl must be before the synchro, so if the parent
* dies before we set the parent death signal, we will detect
* its death with the synchro right after, otherwise we have
* a window where the parent can exit before we set the pdeath
* signal leading to a unsupervized container.
*/
if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0)) {
SYSERROR("failed to set pdeath signal");
return -1;
}
lxc_sync_fini_parent(handler);
/* Tell the parent task it can begin to configure the
@ -441,11 +452,6 @@ static int do_start(void *data)
return -1;
}
if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0)) {
SYSERROR("failed to set pdeath signal");
return -1;
}
close(handler->sigfd);
/* after this call, we are in error because this