Skip to content

Commit

Permalink
kselftest: signal all child processes
Browse files Browse the repository at this point in the history
We have some many cases that will create child process as well, such as
pidfd_wait. Previously, we will signal/kill the parent process when it
is time out, but this signal will not be sent to its child process. In
such case, if child process doesn't terminate itself, ksefltest framework
will hang forever.

Here we group all its child processes so that kill() can signal all of
them in timeout.

Fixed change log: Shuah Khan <skhan@linuxfoundation.org>

Suggested-by: yang xu <xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
  • Loading branch information
Li Zhijian authored and Shuah Khan committed Jan 25, 2022
1 parent 40d70d4 commit 92d2563
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/testing/selftests/kselftest_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,8 @@ static void __timeout_handler(int sig, siginfo_t *info, void *ucontext)
}

t->timed_out = true;
kill(t->pid, SIGKILL);
// signal process group
kill(-(t->pid), SIGKILL);
}

void __wait_for_test(struct __test_metadata *t)
Expand Down Expand Up @@ -987,6 +988,7 @@ void __run_test(struct __fixture_metadata *f,
ksft_print_msg("ERROR SPAWNING TEST CHILD\n");
t->passed = 0;
} else if (t->pid == 0) {
setpgrp();
t->fn(t, variant);
if (t->skip)
_exit(255);
Expand Down

0 comments on commit 92d2563

Please sign in to comment.