From: Christian Brauner Date: Tue, 18 Jan 2022 15:26:58 +0000 (+0100) Subject: conf: log termination status X-Git-Tag: lxc-5.0.0~37^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5af72a666e3027a032c4ac4ea3df3880a51b907;p=thirdparty%2Flxc.git conf: log termination status Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 62ea6ae54..74bf5178d 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -5566,9 +5566,19 @@ on_error: /* Wait for child to finish. */ if (pid < 0) - return -1; + return log_error(-1, "Failed to create child process"); - return wait_for_pid(pid); + ret = lxc_wait_for_pid_status(pid); + if (ret < 0) + return syserror("Failed to wait on child process %d", pid); + if (WIFSIGNALED(ret)) + return log_error(-1, "Child process %d terminated by signal %ld", pid, WTERMSIG(ret)); + if (!WIFEXITED(ret)) + return log_error(-1, "Child did not termiate correctly"); + if (WEXITSTATUS(ret)) + return log_error(-1, "Child terminated with error %ld", WEXITSTATUS(ret)); + + return 0; } /* not thread-safe, do not use from api without first forking */