All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/selftests: Avoid backgroud process/threads
@ 2018-07-31 14:10 Breno Leitao
  2018-08-03 10:36 ` Michael Ellerman
  0 siblings, 1 reply; 8+ messages in thread
From: Breno Leitao @ 2018-07-31 14:10 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Breno Leitao, Gustavo Romero

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@debian.org>
Signed-off-by: Gustavo Romero <gromero@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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-08-14  4:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-31 14:10 [PATCH] powerpc/selftests: Avoid backgroud process/threads Breno Leitao
2018-08-03 10:36 ` Michael Ellerman
2018-08-03 14:37   ` [PATCH v2] selftests/powerpc: Avoid remaining process/threads Breno Leitao
2018-08-06 11:06     ` Michael Ellerman
2018-08-06 18:24       ` Breno Leitao
2018-08-07 14:15         ` [PATCH v3] selftests/powerpc: Kill child processes on SIGINT Breno Leitao
2018-08-13 11:23           ` [v3] " Michael Ellerman
2018-08-14  4:16         ` [PATCH v2] selftests/powerpc: Avoid remaining process/threads Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.