From c7a5c6cb26a1faecf841662b8e156e7b7d333793 Mon Sep 17 00:00:00 2001 From: Travis Rivera Petit Date: Tue, 7 Apr 2026 15:32:41 +0200 Subject: [PATCH 1/4] Fix process group termination: always send SIGKILL after SIGTERM --- lab/calls/call.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lab/calls/call.py b/lab/calls/call.py index 7c6e5cb2e..5d39dae72 100644 --- a/lab/calls/call.py +++ b/lab/calls/call.py @@ -242,13 +242,20 @@ def _update_cpu_time(self): def _terminate_process_group(self): """Terminate the entire process group (parent and all children).""" + try: + pgid = os.getpgid(self.process.pid) + except (OSError, ProcessLookupError): + return + with contextlib.suppress(OSError, ProcessLookupError): - os.killpg(os.getpgid(self.process.pid), signal.SIGTERM) + os.killpg(pgid, signal.SIGTERM) + # Give it a moment to terminate gracefully. time.sleep(1) - if self.process.poll() is None: - with contextlib.suppress(OSError, ProcessLookupError): - os.killpg(os.getpgid(self.process.pid), signal.SIGKILL) + + with contextlib.suppress(OSError, ProcessLookupError): + os.killpg(pgid, signal.SIGKILL) + def _monitor_time_limits(self): """ From 04056f327939eebac5b5faecd30e216070fd5b69 Mon Sep 17 00:00:00 2001 From: Travis Rivera Petit Date: Tue, 7 Apr 2026 15:48:29 +0200 Subject: [PATCH 2/4] Fix formatting --- lab/calls/call.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lab/calls/call.py b/lab/calls/call.py index 5d39dae72..246b0ad30 100644 --- a/lab/calls/call.py +++ b/lab/calls/call.py @@ -246,17 +246,16 @@ def _terminate_process_group(self): pgid = os.getpgid(self.process.pid) except (OSError, ProcessLookupError): return - + with contextlib.suppress(OSError, ProcessLookupError): os.killpg(pgid, signal.SIGTERM) # Give it a moment to terminate gracefully. time.sleep(1) - + with contextlib.suppress(OSError, ProcessLookupError): os.killpg(pgid, signal.SIGKILL) - def _monitor_time_limits(self): """ Monitor the CPU time and wall-clock time of the process. From b08cbda120fef99e652b2ccbb29e04e5c11e1d9a Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Sat, 2 May 2026 13:42:53 +0200 Subject: [PATCH 3/4] Don't kill processes that already exited. --- lab/calls/call.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lab/calls/call.py b/lab/calls/call.py index 246b0ad30..4491c240a 100644 --- a/lab/calls/call.py +++ b/lab/calls/call.py @@ -242,6 +242,9 @@ def _update_cpu_time(self): def _terminate_process_group(self): """Terminate the entire process group (parent and all children).""" + # Resolve the pgid once: after SIGTERM the leader may exit and be + # reaped, making a later os.getpgid(self.process.pid) fail even + # though children in the group are still running. try: pgid = os.getpgid(self.process.pid) except (OSError, ProcessLookupError): @@ -253,6 +256,17 @@ def _terminate_process_group(self): # Give it a moment to terminate gracefully. time.sleep(1) + # We can't use self.process.poll() to decide whether to escalate: + # poll() only tracks the leader, but a wrapper leader (e.g. + # fast-downward.py) can exit cleanly after SIGTERM while its + # children (translate, search) keep running in the group. Probing + # the group with signal 0 tells us whether any member is still + # alive. + try: + os.killpg(pgid, 0) + except (OSError, ProcessLookupError): + return + with contextlib.suppress(OSError, ProcessLookupError): os.killpg(pgid, signal.SIGKILL) From 5b35e31f4bab0e04437199080cfd65844227de37 Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Sat, 2 May 2026 13:53:24 +0200 Subject: [PATCH 4/4] Add changelog entry. --- docs/news.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/news.rst b/docs/news.rst index 8cbfd00a0..15a405229 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -1,6 +1,14 @@ Changelog ========= +next (unreleased) +----------------- + +Lab +^^^ +* Fix process group termination: always escalate to ``SIGKILL`` after ``SIGTERM``, since the previous ``poll()``-based check on the leader missed cases where a wrapper script exited cleanly while its children kept running (Travis Rivera Petit). + + v8.9 (2026-02-25) -----------------