[ptest-runner,v2,2/4] use process groups when spawning

Submitted by Randy MacLeod on June 14, 2019, 2:48 p.m. | Patch ID: 162212

Details

Message ID 20190614144853.25839-3-Randy.MacLeod@windriver.com
State New
Headers show

Commit Message

Randy MacLeod June 14, 2019, 2:48 p.m.
From: Richard Purdie <richard.purdie@linuxfoundation.org>

Rather than just killing the process we've swawned, set the process group
for spawned children and then kill the group of processes.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Upstream-Status: Pending [code being tested]
---
 utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/utils.c b/utils.c
index 9fab6f2..86dcdad 100644
--- a/utils.c
+++ b/utils.c
@@ -330,7 +330,7 @@  wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
 			clock_gettime(clock, &time);
 			if ((time.tv_sec - sentinel.tv_sec) > timeout) {
 				*timeouted = 1;
-				kill(pid, SIGKILL);
+				kill(-pid, SIGKILL);
 				waitflags = 0;
 			}
 		}
@@ -392,6 +392,7 @@  run_ptests(struct ptest_list *head, const struct ptest_options opts,
 				rc = -1;
 				break;
 			} else if (child == 0) {
+				setsid();
 				run_child(p->run_ptest, pipefd_stdout[1], pipefd_stderr[1]);
 			} else {
 				int status;