|
23 | 23 | from asyncio.windows_utils import Popen |
24 | 24 | from signal import CTRL_C_EVENT as SIG_INTERRUPT |
25 | 25 | from signal import SIGTERM |
26 | | - from subprocess import CREATE_NEW_PROCESS_GROUP |
27 | 26 |
|
28 | 27 | from .read_via_thread_windows import ReadViaThreadWindows as ReadViaThread |
29 | 28 |
|
30 | | - CREATION_FLAGS = CREATE_NEW_PROCESS_GROUP # a custom flag needed for Windows signal send ability (CTRL+C) |
31 | 29 | else: # pragma: win32 no cover |
32 | 30 | from signal import SIGINT as SIG_INTERRUPT |
33 | 31 | from signal import SIGKILL, SIGTERM |
34 | 32 | from subprocess import Popen |
35 | 33 |
|
36 | 34 | from .read_via_thread_unix import ReadViaThreadUnix as ReadViaThread |
37 | 35 |
|
38 | | - CREATION_FLAGS = 0 |
39 | | - |
40 | 36 |
|
41 | 37 | IS_WIN = sys.platform == "win32" |
42 | 38 |
|
@@ -67,9 +63,10 @@ def interrupt(self) -> None: |
67 | 63 | msg = "requested interrupt of %d from %d, activate in %.2f" |
68 | 64 | logging.warning(msg, to_pid, host_pid, self.options.suicide_timeout) |
69 | 65 | if self.wait(self.options.suicide_timeout) is None: # still alive -> INT |
70 | | - msg = "send signal %s to %d from %d with timeout %.2f" |
71 | | - logging.warning(msg, f"SIGINT({SIG_INTERRUPT})", to_pid, host_pid, self.options.interrupt_timeout) |
72 | | - self._process.send_signal(SIG_INTERRUPT) |
| 66 | + if sys.platform != "win32": # on Windows everyone in the same process group, so they got the message |
| 67 | + msg = "send signal %s to %d from %d with timeout %.2f" |
| 68 | + logging.warning(msg, f"SIGINT({SIG_INTERRUPT})", to_pid, host_pid, self.options.interrupt_timeout) |
| 69 | + self._process.send_signal(SIG_INTERRUPT) |
73 | 70 | if self.wait(self.options.interrupt_timeout) is None: # still alive -> TERM # pragma: no branch |
74 | 71 | terminate_output = self.options.terminate_timeout |
75 | 72 | logging.warning(msg, f"SIGTERM({SIGTERM})", to_pid, host_pid, terminate_output) |
@@ -198,7 +195,6 @@ def __enter__(self) -> ExecuteStatus: |
198 | 195 | stdin={StdinSource.USER: None, StdinSource.OFF: DEVNULL, StdinSource.API: PIPE}[self.request.stdin], |
199 | 196 | cwd=str(self.request.cwd), |
200 | 197 | env=self.request.env, |
201 | | - creationflags=CREATION_FLAGS, |
202 | 198 | ) |
203 | 199 | except OSError as exception: |
204 | 200 | return LocalSubprocessExecuteFailedStatus(self.options, self._out, self._err, exception.errno) |
|
0 commit comments