Skip to content

Commit 11ed25a

Browse files
committed
Merge remote-tracking branch 'origin/topic/awelzel/avoid-escaped-processes'
* origin/topic/awelzel/avoid-escaped-processes: btest-setsid: Fail on setsid() error btest-bg-run-helper: Ignore SIGTERM to self during cleanup
2 parents 5ffb12e + d3a3b05 commit 11ed25a

File tree

7 files changed

+28
-6
lines changed

7 files changed

+28
-6
lines changed

CHANGES

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
1.1-23 | 2024-12-04 19:18:04 +0100
2+
3+
* btest-setsid: Fail on setsid() error (Arne Welzel, Corelight)
4+
5+
* btest-bg-run-helper: Ignore SIGTERM to self during cleanup (Arne Welzel, Corelight)
6+
7+
The kill 0 invocation would kill the btest-bg-run-helper itself,
8+
causing the subsequent logic to not be executed, resulting in
9+
runaway processes on the system.
10+
111
1.1-20 | 2024-12-04 08:46:27 -0700
212

313
* Fix ruff UP check findings (Tim Wojtulewicz, Corelight)

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
..
33
.. Version number is filled in automatically.
44

5-
.. |version| replace:: 1.1-20
5+
.. |version| replace:: 1.1-23
66

77
==================================================
88
BTest - A Generic Driver for Powerful System Tests

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1-20
1+
1.1-23

btest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ else:
5656
import multiprocessing.managers as mp_managers
5757
import multiprocessing.sharedctypes as mp_sharedctypes
5858

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

6161
Name = "btest"
6262
Config = None

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

btest-setsid

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import sys
55

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

1112
prog = sys.argv[1]
1213
args = sys.argv[1:]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
py_modules = ["btest-sphinx"]
66

77
setup(
8-
version="1.1.dev20", # Filled in automatically.
8+
version="1.1.dev23", # Filled in automatically.
99
py_modules=py_modules,
1010
)

0 commit comments

Comments
 (0)