Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btest-bg-run-helper: Ignore SIGTERM to self during cleanup #105

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions btest-bg-run-helper
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
# Internal helper for btest-bg-run.

cleanup() {
# Ignore SIGTERM during cleanup to prevent terminating
# this process when sending signals to the process group.
trap true SIGTERM

if [ ! -e .exitcode ]; then
echo 15 >.exitcode

# Send SIGTERM to all processes in the process group
# of the calling process.
#
# This should terminate any well-behaved background
# commands that were spawned by the program under test
# unless they started their own process group.
awelzel marked this conversation as resolved.
Show resolved Hide resolved
kill 0 &>/dev/null

if [ -n "$pid" ]; then
Expand Down
5 changes: 3 additions & 2 deletions btest-setsid
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import sys

try:
os.setsid()
except Exception:
pass
except Exception as e:
print(f"btest-setsid failed: {e!r}", file=sys.stderr)
exit(1)

prog = sys.argv[1]
args = sys.argv[1:]
Expand Down
Loading