aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-10-01 13:55:13 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-10-05 12:09:45 +0200
commit130194aa0e538700c21e70bc81f6ae04cc2b95d1 (patch)
tree40009b292642843365c8a7e4d28c40820e98987a
parent1ebfd3834a82b2a638377e3572c1039ded4562e9 (diff)
downloadlibssh-130194aa0e538700c21e70bc81f6ae04cc2b95d1.tar.gz
libssh-130194aa0e538700c21e70bc81f6ae04cc2b95d1.tar.xz
libssh-130194aa0e538700c21e70bc81f6ae04cc2b95d1.zip
torture: Improve process termination function
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> (cherry-picked from commit 0e98f121)
-rw-r--r--tests/torture.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/torture.c b/tests/torture.c
index 30f9ab36..a4f38ad3 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -351,6 +351,8 @@ int torture_terminate_process(const char *pidfile)
ssize_t rc;
pid_t pid;
int fd;
+ int is_running = 1;
+ int count;
/* read the pidfile */
fd = open(pidfile, O_RDONLY);
@@ -373,11 +375,20 @@ int torture_terminate_process(const char *pidfile)
pid = (pid_t)(tmp & 0xFFFF);
- /* Make sure the process 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 = 0;
+ break;
+ }
+ }
+
+ if (is_running) {
fprintf(stderr,
"WARNING: The process server is still running!\n");
}
@@ -890,7 +901,7 @@ void torture_teardown_sshd_server(void **state)
rc = torture_terminate_process(s->srv_pidfile);
if (rc != 0) {
- fprintf(stderr, "Failed to terminate sshd");
+ fprintf(stderr, "XXXXXX Failed to terminate sshd\n");
}
torture_teardown_socket_dir(state);