From 2f6ef4b6237ae8d2f097fc29a02665b25824c278 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 --- src/tests/qemu/Makefile | 2 +- src/tests/qemu/init.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/tests/qemu') diff --git a/src/tests/qemu/Makefile b/src/tests/qemu/Makefile index b60aa5a..a1ece9b 100644 --- a/src/tests/qemu/Makefile +++ b/src/tests/qemu/Makefile @@ -45,7 +45,7 @@ KERNEL_BZIMAGE := $(KERNEL_PATH)/arch/x86/boot/bzImage $(eval $(call tar_download,MUSL,musl,1.1.15,.tar.gz,https://www.musl-libc.org/releases/)) $(eval $(call tar_download,LIBMNL,libmnl,1.0.4,.tar.bz2,http://ftp.netfilter.org/pub/libmnl/)) $(eval $(call tar_download,IPERF,iperf,3.1.3,.tar.gz,http://downloads.es.net/pub/iperf/)) -$(eval $(call tar_download,BASH,bash,30a978b7d808c067219c95be88c4979b6a7aa251,.tar.gz,http://git.savannah.gnu.org/cgit/bash.git/snapshot/)) +$(eval $(call tar_download,BASH,bash,f459cbd8be37b28be1dc90315e0ab51d7f211301,.tar.gz,http://git.savannah.gnu.org/cgit/bash.git/snapshot/)) $(eval $(call tar_download,IPROUTE2,iproute2,4.3.0,.tar.gz,http://www.kernel.org/pub/linux/utils/net/iproute2/)) $(eval $(call tar_download,IPTABLES,iptables,1.6.0,.tar.bz2,http://ftp.netfilter.org/pub/iptables/)) $(eval $(call tar_download,NMAP,nmap,7.25BETA1,.tar.bz2,http://nmap.org/dist/)) 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-59-g8ed1b