aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/powerpc/harness.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/powerpc/harness.c')
-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)
30 30
31 pid = fork(); 31 pid = fork();
32 if (pid == 0) { 32 if (pid == 0) {
33 setpgid(0, 0);
33 exit(test_function()); 34 exit(test_function());
34 } else if (pid == -1) { 35 } else if (pid == -1) {
35 perror("fork"); 36 perror("fork");
36 return 1; 37 return 1;
37 } 38 }
38 39
40 setpgid(pid, pid);
41
39 /* Wake us up in timeout seconds */ 42 /* Wake us up in timeout seconds */
40 alarm(TIMEOUT); 43 alarm(TIMEOUT);
41 terminated = false; 44 terminated = false;
@@ -50,17 +53,20 @@ wait:
50 53
51 if (terminated) { 54 if (terminated) {
52 printf("!! force killing %s\n", name); 55 printf("!! force killing %s\n", name);
53 kill(pid, SIGKILL); 56 kill(-pid, SIGKILL);
54 return 1; 57 return 1;
55 } else { 58 } else {
56 printf("!! killing %s\n", name); 59 printf("!! killing %s\n", name);
57 kill(pid, SIGTERM); 60 kill(-pid, SIGTERM);
58 terminated = true; 61 terminated = true;
59 alarm(KILL_TIMEOUT); 62 alarm(KILL_TIMEOUT);
60 goto wait; 63 goto wait;
61 } 64 }
62 } 65 }
63 66
67 /* Kill anything else in the process group that is still running */
68 kill(-pid, SIGTERM);
69
64 if (WIFEXITED(status)) 70 if (WIFEXITED(status))
65 status = WEXITSTATUS(status); 71 status = WEXITSTATUS(status);
66 else { 72 else {