All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 3/3] lib/tst_test.c: Kill all children on timeout
@ 2016-06-07 12:45 Cyril Hrubis
  2016-06-08  8:23 ` Jan Stancek
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2016-06-07 12:45 UTC (permalink / raw)
  To: ltp

* Run actuall test in a separate process group

* Deliver SIGKILL to all children on timeout

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/newlib_tests/.gitignore |  1 +
 lib/newlib_tests/test13.c   | 37 +++++++++++++++++++++++++++++++++++++
 lib/tst_test.c              |  6 ++++--
 3 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 lib/newlib_tests/test13.c

diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
index dccf4c8..ea19310 100644
--- a/lib/newlib_tests/.gitignore
+++ b/lib/newlib_tests/.gitignore
@@ -10,3 +10,4 @@ test09
 test10
 test11
 test12
+test13
diff --git a/lib/newlib_tests/test13.c b/lib/newlib_tests/test13.c
new file mode 100644
index 0000000..7ad5172
--- /dev/null
+++ b/lib/newlib_tests/test13.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Linux Test Project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * Test for timeout & children.
+ */
+
+#include "tst_test.h"
+
+static void do_test(void)
+{
+	SAFE_FORK();
+	SAFE_FORK();
+	SAFE_FORK();
+
+	tst_res(TINFO, "Pausing process pid %i", getpid());
+	pause();
+}
+
+static struct tst_test test = {
+	.tid = "test13",
+	.timeout = 1,
+	.forks_child = 1,
+	.test_all = do_test,
+};
diff --git a/lib/tst_test.c b/lib/tst_test.c
index eef54e4..9122f57 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -660,7 +660,7 @@ static unsigned int timeout = 300;
 
 static void alarm_handler(int sig LTP_ATTRIBUTE_UNUSED)
 {
-	kill(test_pid, SIGKILL);
+	kill(-test_pid, SIGKILL);
 }
 
 static void heartbeat_handler(int sig LTP_ATTRIBUTE_UNUSED)
@@ -702,8 +702,10 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
 	if (test_pid < 0)
 		tst_brk(TBROK | TERRNO, "fork()");
 
-	if (!test_pid)
+	if (!test_pid) {
+		SAFE_SETPGID(0, 0);
 		testrun();
+	}
 
 	SAFE_WAITPID(test_pid, &status, 0);
 
-- 
2.7.3


-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 3/3] lib/tst_test.c: Kill all children on timeout
  2016-06-07 12:45 [LTP] [PATCH 3/3] lib/tst_test.c: Kill all children on timeout Cyril Hrubis
@ 2016-06-08  8:23 ` Jan Stancek
  2016-06-08  9:48   ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2016-06-08  8:23 UTC (permalink / raw)
  To: ltp




----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: ltp@lists.linux.it
> Sent: Tuesday, 7 June, 2016 2:45:07 PM
> Subject: [LTP] [PATCH 3/3] lib/tst_test.c: Kill all children on timeout
> 
> * Run actuall test in a separate process group
> 
> * Deliver SIGKILL to all children on timeout
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>

ACK.

Is there a 2/3? I can't seem to find the series this patch belongs to.
I assume 1/3 was "lib/tst_test.c: Run test in child process".

Regards,
Jan

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

* [LTP] [PATCH 3/3] lib/tst_test.c: Kill all children on timeout
  2016-06-08  8:23 ` Jan Stancek
@ 2016-06-08  9:48   ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2016-06-08  9:48 UTC (permalink / raw)
  To: ltp

Hi!
> ACK.
> 
> Is there a 2/3? I can't seem to find the series this patch belongs to.
> I assume 1/3 was "lib/tst_test.c: Run test in child process".

I should have deleted the 3/3 in order to make it less confusing.

The 2/3 would have been the SAFE_SETPGID() patch that I deemed to be
obvious enough to be commited directly.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2016-06-08  9:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 12:45 [LTP] [PATCH 3/3] lib/tst_test.c: Kill all children on timeout Cyril Hrubis
2016-06-08  8:23 ` Jan Stancek
2016-06-08  9:48   ` 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.