summaryrefslogtreecommitdiff
path: root/lib/drmtest.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-11 14:29:00 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-11 14:29:00 +0200
commit9fb316a6db16cd8cddba719d7acbdf068f9238ee (patch)
tree445523ba01697f94f7421c766f4f4745d64bfb8a /lib/drmtest.c
parent1978aecf1d22f21265d64099e70565d6e5e384cc (diff)
lib/drmtest: clean up children in an exit handler
Also be a bit more careful with killing them in general. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib/drmtest.c')
-rw-r--r--lib/drmtest.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 969854c6f..f2590d746 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -967,8 +967,10 @@ static void fork_helper_exit_handler(int sig)
/* Someone forgot to fill up the array? */
assert(pid != 0);
- kill(pid, SIGQUIT);
- waitpid(pid, &status, 0);
+ assert(kill(pid, SIGQUIT) == 0);
+ while (waitpid(pid, &status, 0) == -1 &&
+ errno == -EINTR)
+ ;
helper_process_count--;
}
}
@@ -1023,7 +1025,7 @@ void igt_stop_helper(struct igt_helper_process *proc)
assert(proc->running);
- kill(proc->pid, SIGQUIT);
+ assert(kill(proc->pid, SIGQUIT) == 0);
waitpid(proc->pid, &status, 0);
proc->running = false;
@@ -1032,11 +1034,29 @@ void igt_stop_helper(struct igt_helper_process *proc)
helper_process_count--;
}
+static void children_exit_handler(int sig)
+{
+ assert(!test_child);
+
+ for (int nc = 0; nc < num_test_children; nc++) {
+ int status = -1;
+ assert(kill(test_children[nc], SIGQUIT) == 0);
+
+ while (waitpid(test_children[nc], &status, 0) == -1 &&
+ errno == -EINTR)
+ ;
+ }
+
+ num_test_children = 0;
+}
+
bool __igt_fork(void)
{
assert(!test_with_subtests || in_subtest);
assert(!test_child);
+ igt_install_exit_handler(children_exit_handler);
+
if (num_test_children >= test_children_sz) {
if (!test_children_sz)
test_children_sz = 4;