From a85f4b7349e2ce2aadc2546609578289aa886676 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 2 Dec 2016 11:59:35 +0100 Subject: tests: make sure ncat gets killed Signed-off-by: Jason A. Donenfeld --- src/tests/qemu/init.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/tests/qemu/init.c') diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c index 62157c0..d23ec37 100644 --- a/src/tests/qemu/init.c +++ b/src/tests/qemu/init.c @@ -144,18 +144,17 @@ static void kmod_selftests(void) static void launch_tests(void) { int status, fd; + pid_t pid; pretty_message("[+] Launching tests..."); - switch (fork()) { - case -1: + pid = fork(); + if (pid == -1) panic("fork"); - break; - case 0: + else if (pid == 0) { execl("/init.sh", "init", NULL); panic("exec"); - break; } - if (wait(&status) < 0) - panic("wait"); + if (waitpid(pid, &status, 0) < 0) + panic("waitpid"); if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { pretty_message("[+] Tests successful! :-)"); fd = open("/dev/vport1p1", O_WRONLY); -- cgit v1.2.3