[LTP] 72b1728674 causing regressions [ [PATCH v2] Terminate leftover subprocesses when main test process crashes]

Cyril Hrubis chrubis@suse.cz
Fri Feb 18 13:42:40 CET 2022


Hi!
> > > >> --- a/lib/tst_test.c
> > > >> +++ b/lib/tst_test.c
> > > >> @@ -1495,6 +1495,9 @@ static int fork_testrun(void)
> > > >>              return TFAIL;
> > > >>      }
> 
> > > >> +    if (tst_test->forks_child)
> > > >> +            kill(-test_pid, SIGKILL);
> FYI This broke all LTP network tests which use netstress.c binary,
> they now randomly fails after "tst_test.c:1499: TINFO: Killed the leftover descendant processes"
> 
> I was thinking whether it's not actually kernel bug which is now visible,
> but the behavior is the same on various kernels: SLES 5.14, openSUSE 5.16.8,
> older Debian 5.3. and different VM setup (but disabled firewall, also randomly
> failing means it's not a firewall issue).
> 
> Not sure now whether netstress.c should be altered or we should add flag to the
> API to not run this cleanup.
> 
> DEBUGGING:
> 
> The reason is hidden, because netstress.c output is redirected and printed only
> on error.
> 
> Sometimes it's just a warning:

I guess that it's a race between the SETSID() and exit(0) in the
move_to_background() function. If the main test process calls exit(0)
before the newly forked child managed to do SETSID() it's killed by the
test library because it's still in the old process group.

Try this:

diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 0914c65bd..04a850134 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -713,11 +713,15 @@ static void server_cleanup(void)

 static void move_to_background(void)
 {
-       if (SAFE_FORK())
+       if (SAFE_FORK()) {
+               pause();
                exit(0);
+       }

        SAFE_SETSID();

+       SAFE_KILL(getppid(), SIGUSR1);
+
        close(STDIN_FILENO);
        SAFE_OPEN("/dev/null", O_RDONLY);
        close(STDOUT_FILENO);


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list