privops: wait for helper pid
Save the pid of the helper process and replace wait() with waitpid().
This commit is contained in:
parent
1b8ee3259e
commit
aa9a4c697c
1 changed files with 3 additions and 1 deletions
|
@ -92,6 +92,7 @@ typedef struct {
|
||||||
} PrvResponse;
|
} PrvResponse;
|
||||||
|
|
||||||
static int helper_fd = -1;
|
static int helper_fd = -1;
|
||||||
|
static pid_t helper_pid;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
have_helper(void)
|
have_helper(void)
|
||||||
|
@ -381,7 +382,7 @@ stop_helper(void)
|
||||||
req.op = op_QUIT;
|
req.op = op_QUIT;
|
||||||
send_request(&req);
|
send_request(&req);
|
||||||
|
|
||||||
wait(&status);
|
waitpid(helper_pid, &status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================================================= */
|
/* ======================================================================= */
|
||||||
|
@ -518,6 +519,7 @@ PRV_Initialise(void)
|
||||||
/* parent process */
|
/* parent process */
|
||||||
close(sock_pair[1]);
|
close(sock_pair[1]);
|
||||||
helper_fd = sock_pair[0];
|
helper_fd = sock_pair[0];
|
||||||
|
helper_pid = pid;
|
||||||
|
|
||||||
/* stop the helper even when not exiting cleanly from the main function */
|
/* stop the helper even when not exiting cleanly from the main function */
|
||||||
atexit(stop_helper);
|
atexit(stop_helper);
|
||||||
|
|
Loading…
Reference in a new issue