summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-07-24 12:00:57 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-07-24 12:02:36 +0100
commit66e46630f8ba04060d73e18e46a956bf25201fc4 (patch)
tree5861f986bef2f1a830e19deeb40523daf0290041
parent745945546f7366a413a3a51a37f90caa3a227b1d (diff)
igt_core: Read manpages more carefully for WNOHANG
/me hides I thought it said it would not return for a signal and stopped thinking. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/igt_core.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 1287ff651..b0800e833 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -791,16 +791,24 @@ static void reset_helper_process_list(void)
helper_process_count = 0;
}
-static void fork_helper_exit_handler(int sig)
+static int __waitpid(pid_t pid)
{
- int status;
+ int status = -1;
+ while (waitpid(pid, &status, 0) == -1 &&
+ errno == EINTR)
+ ;
+ return status;
+}
+
+static void fork_helper_exit_handler(int sig)
+{
/* Inside a signal handler, play safe */
for (int i = 0; i < ARRAY_SIZE(helper_process_pids); i++) {
pid_t pid = helper_process_pids[i];
if (pid != -1) {
kill(pid, SIGTERM);
- waitpid(pid, &status, WNOHANG);
+ __waitpid(pid);
helper_process_count--;
}
}
@@ -851,11 +859,11 @@ bool __igt_fork_helper(struct igt_helper_process *proc)
*/
int igt_wait_helper(struct igt_helper_process *proc)
{
- int status = -1;
+ int status;
assert(proc->running);
- waitpid(proc->pid, &status, WNOHANG);
+ status = __waitpid(proc->pid);
proc->running = false;