Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kselftest: signal all child processes

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>

authored by

Li Zhijian and committed by
Shuah Khan
92d25637 40d70d4d

+3 -1
+3 -1
tools/testing/selftests/kselftest_harness.h
··· 877 877 } 878 878 879 879 t->timed_out = true; 880 - kill(t->pid, SIGKILL); 880 + // signal process group 881 + kill(-(t->pid), SIGKILL); 881 882 } 882 883 883 884 void __wait_for_test(struct __test_metadata *t) ··· 988 987 ksft_print_msg("ERROR SPAWNING TEST CHILD\n"); 989 988 t->passed = 0; 990 989 } else if (t->pid == 0) { 990 + setpgrp(); 991 991 t->fn(t, variant); 992 992 if (t->skip) 993 993 _exit(255);