From: Han Pingtian <hanpt@linux.vnet.ibm.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] clone/clone07: only kill child if clone() succeeded
Date: Thu, 14 Apr 2016 16:46:33 +0800 [thread overview]
Message-ID: <20160414084633.GA16717@localhost.localdomain> (raw)
Or when -1 passed as pid to kill(), a lot of processes will be killed.
Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
---
testcases/kernel/syscalls/clone/clone07.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/clone/clone07.c b/testcases/kernel/syscalls/clone/clone07.c
index 8c723de..ed59670 100644
--- a/testcases/kernel/syscalls/clone/clone07.c
+++ b/testcases/kernel/syscalls/clone/clone07.c
@@ -64,6 +64,10 @@ int main(int ac, char **av)
child_pid = ltp_clone(SIGCHLD, do_child, NULL,
CHILD_STACK_SIZE, child_stack);
+
+ if (child_pid < 0)
+ tst_brkm(TBROK | TERRNO, cleanup, "clone failed");
+
if ((wait(&status)) == -1)
tst_brkm(TBROK | TERRNO, cleanup,
"wait failed, status: %d", status);
@@ -107,7 +111,8 @@ static void setup(void)
static void cleanup(void)
{
- kill(child_pid, SIGKILL);
+ if (child_pid > 0)
+ kill(child_pid, SIGKILL);
}
static int do_child(void)
--
1.9.3
next reply other threads:[~2016-04-14 8:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 8:46 Han Pingtian [this message]
2016-04-19 16:44 ` [LTP] [PATCH] clone/clone07: only kill child if clone() succeeded 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=20160414084633.GA16717@localhost.localdomain \
--to=hanpt@linux.vnet.ibm.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