Skip to content

Commit 0fdcfc7

Browse files
committed
btest-bg-run-helper: Ignore SIGTERM to self during cleanup
The kill 0 invocation would kill the btest-bg-run-helper itself, causing the subsequent logic to not be executed, resulting in runaway processes on the system.
1 parent 8e8a51a commit 0fdcfc7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

btest-bg-run-helper

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@
33
# Internal helper for btest-bg-run.
44

55
cleanup() {
6+
# Ignore SIGTERM during cleanup to prevent terminating
7+
# this process when sending signals to the process group.
8+
trap true SIGTERM
9+
610
if [ ! -e .exitcode ]; then
711
echo 15 >.exitcode
12+
13+
# Send SIGTERM to all processes in the process group
14+
# of the calling process.
15+
#
16+
# This should terminate any well-behaved background
17+
# commands that were spawned by the program under test
18+
# unless they started their own process group.
819
kill 0 &>/dev/null
920

1021
if [ -n "$pid" ]; then

0 commit comments

Comments
 (0)