From aa9a4c697ce0b8789a2d24af08a5aa95f487db23 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 8 Dec 2015 16:09:02 +0100 Subject: [PATCH] privops: wait for helper pid Save the pid of the helper process and replace wait() with waitpid(). --- privops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/privops.c b/privops.c index 439b10a..e0967ab 100644 --- a/privops.c +++ b/privops.c @@ -92,6 +92,7 @@ typedef struct { } PrvResponse; static int helper_fd = -1; +static pid_t helper_pid; static int have_helper(void) @@ -381,7 +382,7 @@ stop_helper(void) req.op = op_QUIT; send_request(&req); - wait(&status); + waitpid(helper_pid, &status, 0); } /* ======================================================================= */ @@ -518,6 +519,7 @@ PRV_Initialise(void) /* parent process */ close(sock_pair[1]); helper_fd = sock_pair[0]; + helper_pid = pid; /* stop the helper even when not exiting cleanly from the main function */ atexit(stop_helper);