[PATCH] weston-test-runner: die if parent process dies

U. Artie Eoff ullysses.a.eoff at intel.com
Mon Jun 24 17:24:39 PDT 2013


From: "U. Artie Eoff" <ullysses.a.eoff at intel.com>

Weston check client tests are fork-exec'd by the Weston process
(via the weston-test.so module).  If the Weston process dies, the
client test might not quit in all cases.  This happened in the
subsurface-test described at
https://bugs.freedesktop.org/show_bug.cgi?id=66132 where it went
rogue, eating up 100% cpu.

This does not fix the Weston core-dump issue described in that
bug report.  However, it ensures that the fork-exec'd tests are
killed when its parent process(es) die.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff at intel.com>
---
 tests/weston-test-runner.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/weston-test-runner.c b/tests/weston-test-runner.c
index 27ea9e4..15332a6 100644
--- a/tests/weston-test-runner.c
+++ b/tests/weston-test-runner.c
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/prctl.h>
 #include <string.h>
 #include <assert.h>
 #include <errno.h>
@@ -59,6 +60,9 @@ int main(int argc, char *argv[])
 	int total, pass;
 	siginfo_t info;
 
+	/* die if parent process dies */
+	prctl(PR_SET_PDEATHSIG, SIGHUP);
+
 	if (argc == 2) {
 		t = find_test(argv[1]);
 		if (t == NULL) {
@@ -77,8 +81,12 @@ int main(int argc, char *argv[])
 		pid = fork();
 		assert(pid >= 0);
 
-		if (pid == 0)
+		if (pid == 0) {
+			/* die if parent process dies */
+			prctl(PR_SET_PDEATHSIG, SIGHUP);
+
 			run_test(t); /* never returns */
+		}
 
 		if (waitid(P_ALL, 0, &info, WEXITED)) {
 			fprintf(stderr, "waitid failed: %m\n");
-- 
1.7.11.7



More information about the wayland-devel mailing list