From: Martin Doucha <mdoucha@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: LTP List <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] Terminate leftover subprocesses when main test process crashes
Date: Fri, 11 Feb 2022 10:17:31 +0100 [thread overview]
Message-ID: <014f765e-ce73-e90b-40ac-875cef4842e4@suse.cz> (raw)
In-Reply-To: <CAEemH2cmyRbkQ3-4MvY3jhTaEJ+A430WNyKixE2YRKuyiL6djw@mail.gmail.com>
On 11. 02. 22 7:47, Li Wang wrote:
> On Fri, Feb 11, 2022 at 12:18 AM Martin Doucha <mdoucha@suse.cz
> <mailto:mdoucha@suse.cz>> wrote:
> @@ -1560,6 +1568,7 @@ void tst_run_tcases(int argc, char *argv[],
> struct tst_test *self)
>
> SAFE_SIGNAL(SIGALRM, alarm_handler);
> SAFE_SIGNAL(SIGUSR1, heartbeat_handler);
> + SAFE_SIGNAL(SIGCHLD, sigchild_handler);
>
>
> Do we really need setup this signal handler for SIGCHILD?
>
> Since we have already called 'SAFE_WAITPID(test_pid, &status, 0)'
> in the library process (lib_pid) which rely on SIGCHILD as well.
> And even this handler will be called everytime when test exit normally.
>
> Maybe better just add a kill function to cleanup the remain
> descendants if main test process exit with abonormal status.
>
> e.g.
>
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1503,6 +1503,8 @@ static int fork_testrun(void)
> if (WIFEXITED(status) && WEXITSTATUS(status))
> return WEXITSTATUS(status);
>
> + kill(-test_pid, SIGKILL);
This will not work because at this point, the child process was already
destroyed by waitpid() and all its remaining children were moved under
PID 1 (init). The only place where the grandchildren are still reachable
this way is in SIGCHLD handler while the dead child process still exists
in zombie state.
--
Martin Doucha mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-02-11 9:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 16:18 [LTP] [PATCH] Terminate leftover subprocesses when main test process crashes Martin Doucha
2022-02-11 6:47 ` Li Wang
2022-02-11 7:03 ` Jan Stancek
2022-02-11 7:09 ` Li Wang
2022-02-11 9:17 ` Martin Doucha [this message]
2022-02-11 10:34 ` Li Wang
2022-02-11 11:01 ` Li Wang
2022-02-11 11:35 ` Martin Doucha
2022-02-11 12:15 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=014f765e-ce73-e90b-40ac-875cef4842e4@suse.cz \
--to=mdoucha@suse.cz \
--cc=liwang@redhat.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox