From 01c1b11e45c17d08412e4cf24cfec6640e41403f Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sun, 18 Feb 2018 21:43:46 +0100 Subject: [PATCH] lxccontainer: use wait_for_pid() Signed-off-by: Christian Brauner --- src/lxc/lxccontainer.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 8eab554ed..26fdc23bf 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -746,7 +746,7 @@ again: static bool wait_on_daemonized_start(struct lxc_handler *handler, int pid) { - int state, status; + int ret, state; /* Close write end of the socket pair. */ close(handler->state_socket_pair[1]); @@ -761,12 +761,11 @@ static bool wait_on_daemonized_start(struct lxc_handler *handler, int pid) /* The first child is going to fork() again and then exits. So we reap * the first child here. */ - if (waitpid(pid, &status, 0) < 0) - DEBUG("Failed waiting on first child"); - else if (!WIFEXITED(status)) - DEBUG("Failed to retrieve exit status of first child"); - else if (WEXITSTATUS(status) != 0) - DEBUG("First child exited with: %d", WEXITSTATUS(status)); + ret = wait_for_pid(pid); + if (ret < 0) + DEBUG("Failed waiting on first child %d", pid); + else + DEBUG("First child %d exited", pid); if (state < 0) { SYSERROR("Failed to receive the container state");