This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] test-skeleton: Kill any child process's offspring
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Mon, 23 Sep 2013 21:24:36 +0100
- Subject: [PATCH] test-skeleton: Kill any child process's offspring
- Authentication-results: sourceware.org; auth=none
Hi,
Some of the test cases driven by our test-skeleton create subprocesses.
In a test scenario involving what looks to me like a Linux kernel bug I
have observed stray processes of this kind left behind where their parent
was killed by test-skeleton after a timeout however the process in
question was not. This leads to a clutter in the environment our test
suite is run within and on weaker systems may also affect test results
where the processing power consumed by such a leftover causes the lack of
same for subsequent test cases and consequently timeouts.
The cause of leaving such processes behind is signal_handler that calls
kill to send SIGKILL to test-skeleton's immediate child only and not any
further descendants. Conveniently as the child starts it places itself in
a separate process group that is then inherited by any further children.
Therefore a simple if not obvious fix to this problem is to send SIGKILL
to the child's process group instead which this change implements. There
is no need to wait for any additional descendants left as the exit status
of the immediate child is enough for our purposes and init(8) will take
care of the rest in the unlikely case this change addresses.
The problem itself was observed with nptl/tst-mutexpi9 and that this fix
makes go away -- no stray processes after the test suite has terminated
anymore (nptl/tst-mutexpi9 has its own problem of course on this target,
but that's another matter; I think there's a value in making the test
suite itself more robust).
OK to apply?
2013-09-23 Maciej W. Rozycki <macro@codesourcery.com>
* test-skeleton.c (signal_handler): Send SIGKILL to the child's
process group rather than the child itself.
Maciej
glibc-test-skeleton-kill-pgid.diff
Index: glibc-csl-trunk-2.18/test-skeleton.c
===================================================================
--- glibc-csl-trunk-2.18.orig/test-skeleton.c 2013-09-23 17:20:27.000000000 +0100
+++ glibc-csl-trunk-2.18/test-skeleton.c 2013-09-23 17:52:08.318493273 +0100
@@ -136,8 +136,8 @@ signal_handler (int sig __attribute__ ((
int killed;
int status;
- /* Send signal. */
- kill (pid, SIGKILL);
+ /* Send signal. Target the pgid to reach any child process's offspring. */
+ kill (-pid, SIGKILL);
/* Wait for it to terminate. */
int i;