🐞 bug report
Affected Rule
The issue is caused by the rule: `py_binary`
Is this a regression?
Yes, the previous version in which this bug was not present was: ....
Unsure
Description
A clear and concise description of the problem...
When running a py_binary zipapp (E.g. bazel build --build_python_zip <tgt>) signals such as SIGTERM aren't forwarded to the binary itself, meaning the process doesn't get a chance to clean up.
I suspect
|
ret_code = subprocess.call(subprocess_argv, env=env, cwd=workspace) |
|
print_verbose("subprocess exit code:", ret_code) |
|
sys.exit(ret_code) |
is the source of the issue
🔬 Minimal Reproduction
Given
import signal
signal.signal(signal.SIGTERM, lambda _1, _2: print("SIGTERM"))
while True:
pass
Then bazel run <tgt> and a kill -s TERM <pid> will print SIGTERM. But bazel build --build_python_zip <tgt> followed by a python <tgt>.zip and a kill -s TERM <pid> (of the outer process) results in the process being terminated and the underlying process being orphaned 💔
🔥 Exception or Error
N/A
🌍 Your Environment
Operating System:
Output of bazel version:
Build label: 8.6.0
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Thu Feb 26 19:55:20 2026 (1772135720)
Build timestamp: 1772135720
Build timestamp as int: 1772135720
Rules_python version:
Anything else relevant?
🐞 bug report
Affected Rule
The issue is caused by the rule: `py_binary`Is this a regression?
Yes, the previous version in which this bug was not present was: ....Unsure
Description
A clear and concise description of the problem...When running a
py_binaryzipapp (E.g.bazel build --build_python_zip <tgt>) signals such asSIGTERMaren't forwarded to the binary itself, meaning the process doesn't get a chance to clean up.I suspect
rules_python/python/private/zipapp/zip_main_template.py
Lines 279 to 281 in 25ad57c
🔬 Minimal Reproduction
Given
Then
bazel run <tgt>and akill -s TERM <pid>will printSIGTERM. Butbazel build --build_python_zip <tgt>followed by apython <tgt>.zipand akill -s TERM <pid>(of the outer process) results in the process being terminated and the underlying process being orphaned 💔🔥 Exception or Error
N/A
🌍 Your Environment
Operating System:
Output of
bazel version:Rules_python version:
Anything else relevant?