zdtm: pidns02: Wait till child dead

Submitted by Kirill Tkhai on June 8, 2017, 4:52 p.m.

Details

Message ID 149694073902.30653.17812147413234794136.stgit@localhost.localdomain
State Accepted
Series "zdtm: pidns02: Wait till child dead"
Commit 72cf580cd75de83566226fb6d1fd2776a8081479
Headers show

Commit Message

Kirill Tkhai June 8, 2017, 4:52 p.m.
Wait child before daemonization to do not allow
zdtm.py to see child fds and maps before it
becomes zombie.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 test/zdtm/static/pidns02.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/pidns02.c b/test/zdtm/static/pidns02.c
index 60e4dbdd0..80262f090 100644
--- a/test/zdtm/static/pidns02.c
+++ b/test/zdtm/static/pidns02.c
@@ -149,8 +149,15 @@  int main(int argc, char **argv)
 		goto out;
 	}
 
-	if (kill(pid[1], SIGKILL))
-		pr_perror("Can't kill");
+	if (kill(pid[1], SIGKILL)) {
+		fail("Can't kill");
+		goto out;
+	}
+	ret = waitid(P_PID, pid[1], NULL, WEXITED|WNOWAIT);
+	if (ret) {
+		fail("Can't wait");
+		goto out;
+	}
 
 	test_daemon();
 	test_waitsig();