From 8d72e58a24a94eacaf17e131499bf53e546b4c49 Mon Sep 17 00:00:00 2001 From: 2xsec Date: Tue, 3 Jul 2018 18:16:30 +0900 Subject: [PATCH] tests: cleanup destroytest.c Signed-off-by: 2xsec --- src/tests/destroytest.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tests/destroytest.c b/src/tests/destroytest.c index b8ba8055d7..79549120e4 100644 --- a/src/tests/destroytest.c +++ b/src/tests/destroytest.c @@ -37,24 +37,30 @@ static int create_container(void) perror("fork"); return -1; } + if (pid == 0) { execlp("lxc-create", "lxc-create", "-t", "busybox", "-n", MYNAME, NULL); exit(EXIT_FAILURE); } + again: ret = waitpid(pid, &status, 0); if (ret == -1) { if (errno == EINTR) goto again; + perror("waitpid"); return -1; } + if (ret != pid) goto again; + if (!WIFEXITED(status)) { // did not exit normally fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__); return -1; } + return WEXITSTATUS(status); } @@ -96,6 +102,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "all lxc_container tests passed for %s\n", c->name); ret = 0; + out: lxc_container_put(c); exit(ret);