Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/awelzel/avoid-escaped-proc…
Browse files Browse the repository at this point in the history
…esses'

* origin/topic/awelzel/avoid-escaped-processes:
  btest-setsid: Fail on setsid() error
  btest-bg-run-helper: Ignore SIGTERM to self during cleanup
  • Loading branch information
awelzel committed Dec 4, 2024
2 parents 5ffb12e + d3a3b05 commit 11ed25a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
1.1-23 | 2024-12-04 19:18:04 +0100

* btest-setsid: Fail on setsid() error (Arne Welzel, Corelight)

* btest-bg-run-helper: Ignore SIGTERM to self during cleanup (Arne Welzel, Corelight)

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.1-20 | 2024-12-04 08:46:27 -0700

* Fix ruff UP check findings (Tim Wojtulewicz, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
..
.. Version number is filled in automatically.

.. |version| replace:: 1.1-20
.. |version| replace:: 1.1-23

==================================================
BTest - A Generic Driver for Powerful System Tests
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1-20
1.1-23
2 changes: 1 addition & 1 deletion btest
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ else:
import multiprocessing.managers as mp_managers
import multiprocessing.sharedctypes as mp_sharedctypes

VERSION = "1.1-20" # Automatically filled in.
VERSION = "1.1-23" # Automatically filled in.

Name = "btest"
Config = None
Expand Down
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.
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
py_modules = ["btest-sphinx"]

setup(
version="1.1.dev20", # Filled in automatically.
version="1.1.dev23", # Filled in automatically.
py_modules=py_modules,
)

0 comments on commit 11ed25a

Please sign in to comment.