From: Amitay Isaacs Date: Wed, 22 Nov 2017 00:08:14 +0000 (+1100) Subject: ctdb-tests: Make sure child processes are waited on after termination X-Git-Tag: talloc-2.1.11~383 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c19fc7c9cc94dcf708a3ad0e417304a9d5c965ff;p=thirdparty%2Fsamba.git ctdb-tests: Make sure child processes are waited on after termination Looks like the if a process holding fcntl lock (on pid file) is killed, then the lock is not released till the process is reaped using either wait() or waitpid(). Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- diff --git a/ctdb/tests/src/sock_daemon_test.c b/ctdb/tests/src/sock_daemon_test.c index 505ff78e768..5641d37bcd1 100644 --- a/ctdb/tests/src/sock_daemon_test.c +++ b/ctdb/tests/src/sock_daemon_test.c @@ -984,6 +984,10 @@ static void test5(TALLOC_CTX *mem_ctx, const char *pidfile, ret = kill(pid_server, SIGTERM); assert(ret == 0); + + pid = waitpid(pid_server, &ret, 0); + assert(pid == pid_server); + assert(WEXITSTATUS(ret) == 0); } /* @@ -1272,8 +1276,9 @@ static void test6(TALLOC_CTX *mem_ctx, const char *pidfile, test6_client(sockpath); - pid = wait(&ret); - assert(pid != -1); + pid = waitpid(pid_server, &ret, 0); + assert(pid == pid_server); + assert(WEXITSTATUS(ret) == 0); } /* @@ -1731,6 +1736,10 @@ static void test10(TALLOC_CTX *mem_ctx, const char *pidfile, ret = kill (pid, SIGKILL); assert(ret == 0); + pid2 = waitpid(pid, &ret, 0); + assert(pid2 == pid); + assert(WEXITSTATUS(ret) == 0); + ret = stat(sockpath, &st); assert(ret == 0);