Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Michael Ellerman and committed by
Benjamin Herrenschmidt
de506f73 0a6121cf

+8 -2
+8 -2
tools/testing/selftests/powerpc/harness.c
··· 30 30 31 31 pid = fork(); 32 32 if (pid == 0) { 33 + setpgid(0, 0); 33 34 exit(test_function()); 34 35 } else if (pid == -1) { 35 36 perror("fork"); 36 37 return 1; 37 38 } 39 + 40 + setpgid(pid, pid); 38 41 39 42 /* Wake us up in timeout seconds */ 40 43 alarm(TIMEOUT); ··· 53 50 54 51 if (terminated) { 55 52 printf("!! force killing %s\n", name); 56 - kill(pid, SIGKILL); 53 + kill(-pid, SIGKILL); 57 54 return 1; 58 55 } else { 59 56 printf("!! killing %s\n", name); 60 - kill(pid, SIGTERM); 57 + kill(-pid, SIGTERM); 61 58 terminated = true; 62 59 alarm(KILL_TIMEOUT); 63 60 goto wait; 64 61 } 65 62 } 63 + 64 + /* Kill anything else in the process group that is still running */ 65 + kill(-pid, SIGTERM); 66 66 67 67 if (WIFEXITED(status)) 68 68 status = WEXITSTATUS(status);