summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2014-06-10 22:23:08 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-06-11 17:03:49 +1000
commitde506f73dd40cc1f3ba3312bd454e06f2803335b (patch)
tree35e149b0e30b5b7a24a9bf3a3981f29df279f137 /tools
parent0a6121cf337d8f5183ef1f8a8bca0734f14f4bb1 (diff)
downloadlwn-de506f73dd40cc1f3ba3312bd454e06f2803335b.tar.gz
lwn-de506f73dd40cc1f3ba3312bd454e06f2803335b.zip
selftests/powerpc: Put the test in a separate process group
Allows us to kill the test and any children it has spawned. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/powerpc/harness.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/testing/selftests/powerpc/harness.c b/tools/testing/selftests/powerpc/harness.c
index e80c42a584fe..532ddff8a669 100644
--- a/tools/testing/selftests/powerpc/harness.c
+++ b/tools/testing/selftests/powerpc/harness.c
@@ -30,12 +30,15 @@ int run_test(int (test_function)(void), char *name)
pid = fork();
if (pid == 0) {
+ setpgid(0, 0);
exit(test_function());
} else if (pid == -1) {
perror("fork");
return 1;
}
+ setpgid(pid, pid);
+
/* Wake us up in timeout seconds */
alarm(TIMEOUT);
terminated = false;
@@ -50,17 +53,20 @@ wait:
if (terminated) {
printf("!! force killing %s\n", name);
- kill(pid, SIGKILL);
+ kill(-pid, SIGKILL);
return 1;
} else {
printf("!! killing %s\n", name);
- kill(pid, SIGTERM);
+ kill(-pid, SIGTERM);
terminated = true;
alarm(KILL_TIMEOUT);
goto wait;
}
}
+ /* Kill anything else in the process group that is still running */
+ kill(-pid, SIGTERM);
+
if (WIFEXITED(status))
status = WEXITSTATUS(status);
else {