summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2016-07-28 16:21:44 +1000
committerStefan Metzmacher <metze@samba.org>2016-08-10 11:24:35 +0200
commit38d8bcf89f2796de3dc7318e19fd373fa5e5bb3f (patch)
treed7d47b74560b2f21ab97431939fcb72ace657a4f
parent35f777c0154dec833e8f090cb27623af190919f4 (diff)
downloadsamba-38d8bcf89f2796de3dc7318e19fd373fa5e5bb3f.tar.gz
ctdb-tests: Add explicit wait to the fork_helper()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12109 To create a client process that waits after connect(), instead of trying to do a blocking write(), go to sleep. The parent can then kill the client process, once testing is done. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> (cherry picked from commit 049dd07b909dc56a246799f8a96235989a5a605f)
-rw-r--r--ctdb/tests/src/porting_tests.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/ctdb/tests/src/porting_tests.c b/ctdb/tests/src/porting_tests.c
index c9562876771..146218f2761 100644
--- a/ctdb/tests/src/porting_tests.c
+++ b/ctdb/tests/src/porting_tests.c
@@ -132,16 +132,6 @@ static int socket_client_connect(void)
return client;
}
-static int socket_client_write(int client)
-{
- int ret;
-
- ret = sys_write(client, "\0", 1);
- assert(ret == 1);
-
- return 0;
-}
-
static int socket_client_close(int client)
{
int ret;
@@ -164,8 +154,11 @@ static int fork_helper(void)
assert(pid != -1);
if (pid == 0) { // Child
+ pid = getppid();
client = socket_client_connect();
- socket_client_write(client);
+ while (kill(pid, 0) == 0) {
+ sleep(1);
+ }
socket_client_close(client);
exit(0);
} else {
@@ -204,6 +197,8 @@ static int test_ctdb_get_peer_pid(void)
assert(peer_pid == globals.helper_pid);
+ kill(peer_pid, SIGTERM);
+
close(fd);
return 0;
}