From 6bc415b658dee92d4d981943ce185d25c4646f90 Mon Sep 17 00:00:00 2001 From: Donghwa Jeong Date: Thu, 31 May 2018 17:58:08 +0900 Subject: [PATCH] start: fix waitpid() blocking issue Signed-off-by: Donghwa Jeong --- src/lxc/start.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lxc/start.c b/src/lxc/start.c index be4b1762c..962b7a1fc 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -1824,8 +1824,14 @@ int __lxc_start(const char *name, struct lxc_handler *handler, goto out_abort; } - while (waitpid(handler->pid, &status, 0) < 0 && errno == EINTR) - continue; + if (!handler->init_died && handler->pid > 0) { + ERROR("Child process is not killed"); + goto out_abort; + } + + status = lxc_wait_for_pid_status(handler->pid); + if (status < 0) + SYSERROR("Failed to retrieve status for %d", handler->pid); /* If the child process exited but was not signaled, it didn't call * reboot. This should mean it was an lxc-execute which simply exited. -- 2.47.2