Brad Bishop | d89cb5f | 2019-04-10 09:02:41 -0400 | [diff] [blame^] | 1 | From f0c42a65633341ad048718c7a6dbd035818e9eaf Mon Sep 17 00:00:00 2001 |
| 2 | From: Richard Purdie <richard.purdie@linuxfoundation.org> |
| 3 | Date: Thu, 4 Apr 2019 14:20:31 +0100 |
| 4 | Subject: [PATCH 2/3] use process groups when spawning |
| 5 | |
| 6 | Rather than just killing the process we've swawned, set the process group |
| 7 | for spawned children and then kill the group of processes. |
| 8 | |
| 9 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> |
| 10 | Upstream-Status: Pending [code being tested] |
| 11 | --- |
| 12 | utils.c | 9 +++++---- |
| 13 | 1 file changed, 5 insertions(+), 4 deletions(-) |
| 14 | |
| 15 | diff --git a/utils.c b/utils.c |
| 16 | index 3ceb342..c5b3b8d 100644 |
| 17 | --- a/utils.c |
| 18 | +++ b/utils.c |
| 19 | @@ -309,7 +309,7 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid, |
| 20 | clock_gettime(clock, &time); |
| 21 | if ((time.tv_sec - sentinel.tv_sec) > timeout) { |
| 22 | *timeouted = 1; |
| 23 | - kill(pid, SIGKILL); |
| 24 | + kill(-pid, SIGKILL); |
| 25 | waitflags = 0; |
| 26 | } |
| 27 | } |
| 28 | @@ -371,6 +371,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts, |
| 29 | rc = -1; |
| 30 | break; |
| 31 | } else if (child == 0) { |
| 32 | + setsid(); |
| 33 | run_child(p->run_ptest, pipefd_stdout[1], pipefd_stderr[1]); |
| 34 | } else { |
| 35 | int status; |