From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V3 2/6] tst_test: make reap_children() part of the test API
Date: Thu, 4 Aug 2016 18:13:23 +0200 [thread overview]
Message-ID: <20160804161323.GC3367@rei.lan> (raw)
In-Reply-To: <1470320195-22145-2-git-send-email-stanislav.kholmanskikh@oracle.com>
Hi!
> +[source,c]
> +-------------------------------------------------------------------------------
> +#include "tst_test.h"
> +
> +void tst_reap_children(void);
> +-------------------------------------------------------------------------------
> +
> +The 'tst_reap_children()' function makes the process wait for all of its
> +children and exits with 'tst_brk(TBROK, ...)' if any of them returned
> +a non zero exit code. This function may be called only from the main
> +test process.
There is no reason to limit the function to the main test process only.
All it does it to reap all children and call tst_brk() in case that
someting went wrong.
We can for instance do:
[main test pid]
fork() --> [child]
tst_reap_children() fork() -->[child]
tst_reap_children() tst_brk(TBROK, ...)
In this case the second level child will simply call exit(TBROK), the
first level child will wait it and call exit(TBROK) because the second
level child exitted uncleanly. And finally the main test pid will exit
with TBROK, after a it's cleanup is called (if set).
And it's nearly the same in case of tst_brk(TCONF, ...) but the exit
value will be 0 and the TCONF is instead stored in the result structure
in the shared memory.
Maybe we should include this ascii art diagram in the documentation as
well.
The rest of the patchset is good, acked.
Let's commit it without the sentence that limits this function to the
main test process. I will do something about the documentation later.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2016-08-04 16:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-04 14:16 [LTP] [PATCH V3 1/6] tst_safe_macros: SAFE_GETPGID Stanislav Kholmanskikh
2016-08-04 14:16 ` [LTP] [PATCH V3 2/6] tst_test: make reap_children() part of the test API Stanislav Kholmanskikh
2016-08-04 14:16 ` [LTP] [PATCH V3 3/6] waitpid06: use the new API Stanislav Kholmanskikh
2016-08-04 14:16 ` [LTP] [PATCH V3 4/6] waitpid07: " Stanislav Kholmanskikh
2016-08-04 14:16 ` [LTP] [PATCH V3 5/6] waitpid08: " Stanislav Kholmanskikh
2016-08-04 14:16 ` [LTP] [PATCH V3 6/6] waitpid11: " Stanislav Kholmanskikh
2016-08-04 16:13 ` Cyril Hrubis [this message]
2016-08-05 8:30 ` [LTP] [PATCH V3 2/6] tst_test: make reap_children() part of the test API Cyril Hrubis
2016-08-05 8:56 ` Stanislav Kholmanskikh
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=20160804161323.GC3367@rei.lan \
--to=chrubis@suse.cz \
--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