aboutsummaryrefslogtreecommitdiffstats
path: root/task
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-03-19 23:39:24 -0400
committerEugene Triguba <hello@eugenetriguba.com>2026-03-21 13:37:29 -0400
commitb8148c4785787fd387a662aa1a40837f410b3f14 (patch)
tree1430adba89380921818329161c975a92174f5a71 /task
parentRemove tomli install test (diff)
downloadtaskipy2-b8148c4785787fd387a662aa1a40837f410b3f14.zip
Fix subprocess signal handling logic on linux with ash/dash
Certain shells will have optimizations which will 'exec' commands directly and not spawn a subprocess, which breaks our signal test on those systems.
Diffstat (limited to '')
-rw-r--r--taskipy/task_runner.py10
1 files changed, 3 insertions, 7 deletions
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)