All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] clone/clone07: only kill child if clone() succeeded
@ 2016-04-14  8:46 Han Pingtian
  2016-04-19 16:44 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Han Pingtian @ 2016-04-14  8:46 UTC (permalink / raw)
  To: ltp

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH] clone/clone07: only kill child if clone() succeeded
  2016-04-14  8:46 [LTP] [PATCH] clone/clone07: only kill child if clone() succeeded Han Pingtian
@ 2016-04-19 16:44 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2016-04-19 16:44 UTC (permalink / raw)
  To: ltp

Hi!
>  static void cleanup(void)
>  {
> -	kill(child_pid, SIGKILL);
> +	if (child_pid > 0)
> +		kill(child_pid, SIGKILL);
>  }

Looking at the code, the child does just return 0 (which exits the child
process). There is no need to kill the child_pid in cleanup at all. So
I've removed the cleanup function and pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-19 16:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14  8:46 [LTP] [PATCH] clone/clone07: only kill child if clone() succeeded Han Pingtian
2016-04-19 16:44 ` 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.