From 390cfbef05e42439f82d301752b74f8865f32225 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 2 Oct 2014 06:28:10 +0200 Subject: torture: Check the return code of kill(). CID #73654 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner --- tests/torture.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/torture.c b/tests/torture.c index 02ddc96..eab36de 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -48,6 +48,7 @@ #include #include #include +#include #define TORTURE_ECHO_SRV_IPV4 "127.0.0.10" /* socket wrapper IPv6 prefix fd00::5357:5fxx */ @@ -259,6 +260,8 @@ void torture_teardown_echo_srv(void **state) ssize_t rc; pid_t pid; int fd; + bool is_running = true; + int count; /* read the pidfile */ fd = open(s->srv_pidfile, O_RDONLY); @@ -281,11 +284,20 @@ void torture_teardown_echo_srv(void **state) pid = (pid_t)(tmp & 0xFFFF); - /* Make sure the daemon goes away! */ - kill(pid, SIGTERM); + for (count = 0; count < 10; count++) { + /* Make sure the daemon goes away! */ + kill(pid, SIGTERM); - kill(pid, 0); - if (rc == 0) { + usleep(200); + + rc = kill(pid, 0); + if (rc != 0) { + is_running = false; + break; + } + } + + if (is_running) { fprintf(stderr, "WARNING the echo server is still running!\n"); } -- cgit