* [LTP] [PATCH] waitpid/waitpid02: check if fork failed
@ 2016-04-12 3:03 Han Pingtian
2016-04-12 10:05 ` Cyril Hrubis
0 siblings, 1 reply; 4+ messages in thread
From: Han Pingtian @ 2016-04-12 3:03 UTC (permalink / raw)
To: ltp
Break the test if fork failed. Or this test case will kill a lot of
processes on the system.
Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
---
testcases/kernel/syscalls/waitpid/waitpid02.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/testcases/kernel/syscalls/waitpid/waitpid02.c b/testcases/kernel/syscalls/waitpid/waitpid02.c
index e5d7957..73cdb83 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid02.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid02.c
@@ -96,6 +96,10 @@ int main(int argc, char **argv)
do_child();
#endif
} else {
+ if (pid < 0) {
+ tst_brkm(TBROK|TERRNO, cleanup, "fork failed");
+ }
+
kill(pid, sig);
errno = 0;
while (((npid = waitpid(pid, &status, 0)) != -1) ||
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] waitpid/waitpid02: check if fork failed
2016-04-12 3:03 [LTP] [PATCH] waitpid/waitpid02: check if fork failed Han Pingtian
@ 2016-04-12 10:05 ` Cyril Hrubis
2016-04-12 13:13 ` Han Pingtian
0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2016-04-12 10:05 UTC (permalink / raw)
To: ltp
Hi!
> } else {
> + if (pid < 0) {
> + tst_brkm(TBROK|TERRNO, cleanup, "fork failed");
> + }
The check should be done right after the fork() and not in the else
branch. Also there shoudln't be the curly braces around the tst_brkm()
since it's just a signle line.
Otherwise it's fine.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] waitpid/waitpid02: check if fork failed
2016-04-12 10:05 ` Cyril Hrubis
@ 2016-04-12 13:13 ` Han Pingtian
2016-04-12 13:31 ` Cyril Hrubis
0 siblings, 1 reply; 4+ messages in thread
From: Han Pingtian @ 2016-04-12 13:13 UTC (permalink / raw)
To: ltp
On Tue, Apr 12, 2016 at 12:05:36PM +0200, Cyril Hrubis wrote:
> Hi!
> > } else {
> > + if (pid < 0) {
> > + tst_brkm(TBROK|TERRNO, cleanup, "fork failed");
> > + }
>
> The check should be done right after the fork() and not in the else
> branch. Also there shoudln't be the curly braces around the tst_brkm()
> since it's just a signle line.
>
> Otherwise it's fine.
>
Thanks. This is the new patch.
From 9785b11acc164725a5e93766ec08d199831fd7e5 Mon Sep 17 00:00:00 2001
From: Han Pingtian <hanpt@linux.vnet.ibm.com>
Date: Mon, 11 Apr 2016 23:46:34 +0800
Subject: [PATCH] waitpid/waitpid02: check if fork failed
Break the test if fork failed. Or this test case will kill a lot of
processes on the system.
Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
---
testcases/kernel/syscalls/waitpid/waitpid02.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/testcases/kernel/syscalls/waitpid/waitpid02.c b/testcases/kernel/syscalls/waitpid/waitpid02.c
index e5d7957..7d3a65c 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid02.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid02.c
@@ -88,6 +88,9 @@ int main(int argc, char **argv)
pid = FORK_OR_VFORK();
+ if (pid < 0)
+ tst_brkm(TBROK|TERRNO, cleanup, "fork failed");
+
if (pid == 0) {
#ifdef UCLINUX
self_exec(argv[0], "");
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] waitpid/waitpid02: check if fork failed
2016-04-12 13:13 ` Han Pingtian
@ 2016-04-12 13:31 ` Cyril Hrubis
0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2016-04-12 13:31 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-12 13:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-12 3:03 [LTP] [PATCH] waitpid/waitpid02: check if fork failed Han Pingtian
2016-04-12 10:05 ` Cyril Hrubis
2016-04-12 13:13 ` Han Pingtian
2016-04-12 13:31 ` Cyril Hrubis
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.