Skip to content

Zipapp doesn't forward signals (SIGTERM and friends) to the process, resulting in orphaned processes and no cleanup聽#3809

Description

@thejcannon

馃悶 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:

  
x64 Ubuntu
  

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:

  
1.9.0
  

Anything else relevant?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions