Skip to content

Commit de506f7

Browse files
mpeozbenh
authored andcommitted
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>
1 parent 0a6121c commit de506f7

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎tools/testing/selftests/powerpc/harness.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ int run_test(int (test_function)(void), char *name)
3030

3131
pid = fork();
3232
if (pid == 0) {
33+
setpgid(0, 0);
3334
exit(test_function());
3435
} else if (pid == -1) {
3536
perror("fork");
3637
return 1;
3738
}
3839

40+
setpgid(pid, pid);
41+
3942
/* Wake us up in timeout seconds */
4043
alarm(TIMEOUT);
4144
terminated = false;
@@ -50,17 +53,20 @@ int run_test(int (test_function)(void), char *name)
5053

5154
if (terminated) {
5255
printf("!! force killing %s\n", name);
53-
kill(pid, SIGKILL);
56+
kill(-pid, SIGKILL);
5457
return 1;
5558
} else {
5659
printf("!! killing %s\n", name);
57-
kill(pid, SIGTERM);
60+
kill(-pid, SIGTERM);
5861
terminated = true;
5962
alarm(KILL_TIMEOUT);
6063
goto wait;
6164
}
6265
}
6366

67+
/* Kill anything else in the process group that is still running */
68+
kill(-pid, SIGTERM);
69+
6470
if (WIFEXITED(status))
6571
status = WEXITSTATUS(status);
6672
else {

0 commit comments

Comments
 (0)