aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBreno Leitao <leitao@debian.org>2018-08-07 10:15:39 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2018-08-08 04:52:24 -0400
commit7c27a26e1ed5a7dd709aa19685d2c98f64e1cf0c (patch)
treeda8efad721692b6ceaa83a3ffbf1f7341ec88331
parent77b5f703dcc859915f0f20d92bc538e4a99ef149 (diff)
selftests/powerpc: Kill child processes on SIGINT
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: Breno Leitao <leitao@debian.org> Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--tools/testing/selftests/powerpc/harness.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/testing/selftests/powerpc/harness.c b/tools/testing/selftests/powerpc/harness.c
index 66d31de60b9a..9d7166dfad1e 100644
--- a/tools/testing/selftests/powerpc/harness.c
+++ b/tools/testing/selftests/powerpc/harness.c
@@ -85,13 +85,13 @@ wait:
85 return status; 85 return status;
86} 86}
87 87
88static void alarm_handler(int signum) 88static void sig_handler(int signum)
89{ 89{
90 /* Jut wake us up from waitpid */ 90 /* Just wake us up from waitpid */
91} 91}
92 92
93static struct sigaction alarm_action = { 93static struct sigaction sig_action = {
94 .sa_handler = alarm_handler, 94 .sa_handler = sig_handler,
95}; 95};
96 96
97void test_harness_set_timeout(uint64_t time) 97void test_harness_set_timeout(uint64_t time)
@@ -106,8 +106,14 @@ int test_harness(int (test_function)(void), char *name)
106 test_start(name); 106 test_start(name);
107 test_set_git_version(GIT_VERSION); 107 test_set_git_version(GIT_VERSION);
108 108
109 if (sigaction(SIGALRM, &alarm_action, NULL)) { 109 if (sigaction(SIGINT, &sig_action, NULL)) {
110 perror("sigaction"); 110 perror("sigaction (sigint)");
111 test_error(name);
112 return 1;
113 }
114
115 if (sigaction(SIGALRM, &sig_action, NULL)) {
116 perror("sigaction (sigalrm)");
111 test_error(name); 117 test_error(name);
112 return 1; 118 return 1;
113 } 119 }