-
-
Notifications
You must be signed in to change notification settings - Fork 677
Description
🐞 bug report
Affected Rule
The issue is caused by the rule: py_binary / py_test
Is this a regression?
Yes.
Description
(This bug report is specific to Linux)
In the old 1-stage bootstrap script, the script eventually runs the underlying program with os.execv, which replaces the process entirely, so that's ok - any signals get propagated directly to our program.
def _RunExecv(python_program, main_filename, args, env):
# type: (str, str, list[str], dict[str, str]) -> ...
"""Executes the given Python file using the various environment settings."""
os.environ.update(env)
PrintVerbose("RunExecv: environ:", os.environ)
argv = [python_program, main_filename] + args
PrintVerbose("RunExecv: argv:", python_program, argv)
os.execv(python_program, argv)In the new 2-stage boostrap script(s), the first stage invokes the second stage directly:
env \
"${interpreter_env[@]}" \
"$python_exe" \
"${interpreter_args[@]}" \
"$stage2_bootstrap" \
"$@"
exit $?I'm not sure if it's platform depedent - but at least on Debian and CentOS, bash will start a child process, and signals like SIGINT don't get handled nor propagated.
I think this is a simple fix, changing the stage-2 invocation to:
exec env \
"${interpreter_env[@]}" \
"$python_exe" \
"${interpreter_args[@]}" \
"$stage2_bootstrap" \
"$@"I'm happy to raise a PR for the above if it is agreed to be OK.
🔬 Minimal Reproduction
I don't have one at hand, but I can provide one if needed.
🌍 Your Environment
Operating System:
Linux AMD64 - CentOS 7, and Debian 11
Output of bazel version:
Bazel 7.2.1
Rules_python version:
0.34.0