Commit 82e1e872 authored by Breno Leitao's avatar Breno Leitao Committed by Greg Kroah-Hartman

selftests/powerpc: Kill child processes on SIGINT

[ Upstream commit 7c27a26e1ed5a7dd709aa19685d2c98f64e1cf0c ]

There are some powerpc selftests, as tm/tm-unavailable, that run for a long
period (>120 seconds), and if it is interrupted, as pressing CRTL-C
(SIGINT), the foreground process (harness) dies but the child process and
threads continue to execute (with PPID = 1 now) in background.

In this case, you'd think the whole test exited, but there are remaining
threads and processes being executed in background. Sometimes these
zombies processes are doing annoying things, as consuming the whole CPU or
dumping things to STDOUT.

This patch fixes this problem by attaching an empty signal handler to
SIGINT in the harness process. This handler will interrupt (EINTR) the
parent process waitpid() call, letting the code to follow through the
normal flow, which will kill all the processes in the child process group.

This patch also fixes a typo.
Signed-off-by: default avatarBreno Leitao <>
Signed-off-by: default avatarGustavo Romero <>
Signed-off-by: default avatarMichael Ellerman <>
Signed-off-by: default avatarSasha Levin <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 50f8c8e4
......@@ -85,13 +85,13 @@ wait:
return status;
static void alarm_handler(int signum)
static void sig_handler(int signum)
/* Jut wake us up from waitpid */
/* Just wake us up from waitpid */
static struct sigaction alarm_action = {
.sa_handler = alarm_handler,
static struct sigaction sig_action = {
.sa_handler = sig_handler,
void test_harness_set_timeout(uint64_t time)
......@@ -106,8 +106,14 @@ int test_harness(int (test_function)(void), char *name)
if (sigaction(SIGALRM, &alarm_action, NULL)) {
if (sigaction(SIGINT, &sig_action, NULL)) {
perror("sigaction (sigint)");
return 1;
if (sigaction(SIGALRM, &sig_action, NULL)) {
perror("sigaction (sigalrm)");
return 1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment