bazel-contrib / bazel-contrib/rules_python

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

Offen
#3,809 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Starlark
Sterne
688
Forks
721
Ø Merge
15 Std. 7 Min.
Gemergte PRs (30 T.)
76

Beschreibung

# 🐞 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 `) signals such as `SIGTERM` aren't forwarded to the binary itself, meaning the process doesn't get a chance to clean up.

I suspect https://github.com/bazel-contrib/rules_python/blob/25ad57c85f0094889520486cd9a5738278fd0541/python/private/zipapp/zip_main_template.py#L279-L281 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 ` and a `kill -s TERM ` will print `SIGTERM`. But `bazel build --build_python_zip ` followed by a `python .zip` and a `kill -s TERM ` (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?**

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with python/private/zipapp/zip_main_template.py around lines 279-281, then reproduce the issue with the provided signal-handling Python program. Compare `bazel run` with executing the built zipapp and verify that SIGTERM reaches the underlying process and allows cleanup without leaving it orphaned.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
build-system
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.