diff options
| -rw-r--r-- | CHANGELOG.md | 8 | ||||
| -rw-r--r-- | taskipy/task_runner.py | 10 | ||||
| -rw-r--r-- | tests/test_taskipy.py | 2 | ||||
| -rw-r--r-- | tests/test_windows.py | 2 |
4 files changed, 13 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ae9e5cd..782b013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Fix signal forwarding hanging on Linux when using shells that optimize the + last command with `exec` (e.g. dash, ash). Signal routing now checks whether + child processes actually exist rather than assuming they do based on platform. + ## [1.16.0] - 2026-03-19 ### Changed diff --git a/taskipy/task_runner.py b/taskipy/task_runner.py index cb3b6d6..ffeb682 100644 --- a/taskipy/task_runner.py +++ b/taskipy/task_runner.py @@ -1,7 +1,6 @@ import platform import signal import subprocess -import sys from difflib import get_close_matches from pathlib import Path from types import FrameType @@ -187,13 +186,10 @@ class TaskRunner: def signal_handler(signum: int, _frame): # pylint: disable=W0640 psutil_process_wrapper = psutil.Process(process.pid) - is_direct_subprocess_a_shell_process = sys.platform != 'darwin' # pylint: disable=C0103 + children = psutil_process_wrapper.children() - if is_direct_subprocess_a_shell_process: - # A shell is created because of Popen(..., shell=True) on linux only - # We want here to kill shell's child - sub_processes_of_taskipy_shell = psutil_process_wrapper.children() - for child_process in sub_processes_of_taskipy_shell: + if children: + for child_process in children: child_process.send_signal(signum) else: process.send_signal(signum) diff --git a/tests/test_taskipy.py b/tests/test_taskipy.py index f269ed3..e4c3827 100644 --- a/tests/test_taskipy.py +++ b/tests/test_taskipy.py @@ -412,7 +412,7 @@ class InterruptingTaskTestCase(TaskipyTestCase): process.send_signal(signal.SIGTERM) - exit_code = process.wait() + exit_code = process.wait(timeout=5000) stdout, _ = process.communicate() self.assertEqual(exit_code, 123) diff --git a/tests/test_windows.py b/tests/test_windows.py index 0fde16d..c1d7bca 100644 --- a/tests/test_windows.py +++ b/tests/test_windows.py @@ -14,7 +14,7 @@ class WindowsTestCase(unittest.TestCase): def test_mslex_install(self): '''Ensure that mslex is installed on Windows''' try: - import mslex # type: ignore # pylint: disable=W0611,C0415 + import mslex # type: ignore # pylint: disable=W0611,C0415 # noqa: F401 except ImportError: self.fail('Unable to import mslex') |