Skip to content

The agent that grows with you

fix(process): kill children a SIGTERM-ignoring background shell spawns during the grace window

teknium1e2e2a2fb4304
diff --git a/tools/process_registry.py b/tools/process_registry.py
index 07599328ef1..1aeb66f88d9 100644
--- a/tools/process_registry.py
+++ b/tools/process_registry.py
@@ -1022,6 +1022,14 @@ class ProcessRegistry(ProcessCheckpointMixin):
if grace <= 0:
return
_wait_for_exit(targets)
+ # A parent that ignored SIGTERM (the interactive ``bash -lic`` wrapper does) keeps
+ # running its script through both grace windows and can spawn children the first
+ # snapshot never saw. Re-snapshot while it is still alive: once it is SIGKILLed
+ # they reparent to init and nothing can find them again.
+ with suppress(gone):
+ if cls._proc_alive(parent):
+ known = {proc.pid for proc in targets}
+ targets.extend(p for p in parent.children(recursive=True) if p.pid not in known)
for proc in targets:
with suppress(gone):
if cls._proc_alive(proc):