[PATCH] powerpc/selftests: Avoid backgroud process/threads

Breno Leitao leitao at debian.org
Wed Aug 1 00:10:08 AEST 2018


Current tm-unavailable test runs 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 this case, you'd think the test is gone, but there are two threads being
executed in background, one of the thread ('pong') consumes 100% of the CPU and
the other one ('ping') dumps output message, from time to time, in the STDOUT,
which is annoying.

This patch simply gets the child process to be SIGTERMed when the parent dies.

Signed-off-by: Breno Leitao <leitao at debian.org>
Signed-off-by: Gustavo Romero <gromero at linux.vnet.ibm.com>
---
 tools/testing/selftests/powerpc/tm/tm-unavailable.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/powerpc/tm/tm-unavailable.c b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
index 156c8e750259..c42f8b60063c 100644
--- a/tools/testing/selftests/powerpc/tm/tm-unavailable.c
+++ b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
@@ -23,6 +23,8 @@
 #include <stdbool.h>
 #include <pthread.h>
 #include <sched.h>
+#include <signal.h>
+#include <sys/prctl.h>
 
 #include "tm.h"
 
@@ -342,6 +344,9 @@ int tm_unavailable_test(void)
 
 	SKIP_IF(!have_htm());
 
+	/* Send me SIGTERM if PPID is dead (as SIGINTed) */
+	prctl(PR_SET_PDEATHSIG, SIGTERM);
+
 	/* Set only CPU 0 in the mask. Both threads will be bound to CPU 0. */
 	CPU_ZERO(&cpuset);
 	CPU_SET(0, &cpuset);
-- 
2.16.3



More information about the Linuxppc-dev mailing list