diff options
author | Andreas Schneider <asn@samba.org> | 2014-10-02 06:28:10 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2014-10-20 16:48:21 +0200 |
commit | 390cfbef05e42439f82d301752b74f8865f32225 (patch) | |
tree | 5fb0d8b1b0e3ae8f79077ed54709b6056f14f5fb /tests/torture.c | |
parent | 95c39b39f2f4529b9f59471fd3a99afdd57058ee (diff) | |
download | socket_wrapper-390cfbef05e42439f82d301752b74f8865f32225.tar.gz socket_wrapper-390cfbef05e42439f82d301752b74f8865f32225.tar.xz socket_wrapper-390cfbef05e42439f82d301752b74f8865f32225.zip |
torture: Check the return code of kill().
CID #73654
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Diffstat (limited to 'tests/torture.c')
-rw-r--r-- | tests/torture.c | 20 |
1 files 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 <string.h> #include <unistd.h> #include <time.h> +#include <stdbool.h> #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"); } |