diff mbox

[2/4] lib/drmtest: Add igt_wait_helper

Message ID 1390955106-29853-3-git-send-email-jeff.mcgee@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

jeff.mcgee@intel.com Jan. 29, 2014, 12:25 a.m. UTC
From: Jeff McGee <jeff.mcgee@intel.com>

igt_wait_helper compliments igt_stop_helper and is used when helper
processes are expected to exit naturally.

Signed-off-by: Jeff McGee <jeff.mcgee@intel.com>
---
 lib/drmtest.c | 17 +++++++++++++++++
 lib/drmtest.h |  1 +
 2 files changed, 18 insertions(+)
diff mbox

Patch

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 8bc70a3..d3d81a3 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1241,6 +1241,23 @@  void igt_stop_helper(struct igt_helper_process *proc)
 	helper_process_count--;
 }
 
+void igt_wait_helper(struct igt_helper_process *proc)
+{
+	int status;
+
+	assert(proc->running);
+
+	while (waitpid(proc->pid, &status, 0) == -1 &&
+	       errno == EINTR)
+		;
+	igt_assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+
+	proc->running = false;
+
+	helper_process_pids[proc->id] = -1;
+	helper_process_count--;
+}
+
 static void children_exit_handler(int sig)
 {
 	int ret;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index d42a6f7..f945a7e 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -290,6 +290,7 @@  struct igt_helper_process {
 };
 bool __igt_fork_helper(struct igt_helper_process *proc);
 void igt_stop_helper(struct igt_helper_process *proc);
+void igt_wait_helper(struct igt_helper_process *proc);
 #define igt_fork_helper(proc) \
 	for (; __igt_fork_helper(proc); exit(0))