From 743ecd2efba6b2d2c23a0fdb2fe8958c81c73561 Mon Sep 17 00:00:00 2001 From: Daniel Lezcano Date: Tue, 6 Jul 2010 21:26:31 +0200 Subject: [PATCH] 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 --- src/lxc/start.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lxc/start.c b/src/lxc/start.c index b69ac88f3..dc57bea8e 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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