Skip to content

Commit 05a302c

Browse files
committed
Fixed a non-Windows import
signal.SIGKILL is not available on Windows so use signal.SIGTERM as a backup when SIGKILL is not available.
1 parent b295c13 commit 05a302c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

git/cmd.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import mmap
1515

1616
from contextlib import contextmanager
17-
from signal import SIGKILL
17+
import signal
1818
from subprocess import (
1919
call,
2020
Popen,
@@ -617,10 +617,12 @@ def _kill_process(pid):
617617
if local_pid.isdigit():
618618
child_pids.append(int(local_pid))
619619
try:
620-
os.kill(pid, SIGKILL)
620+
# Windows does not have SIGKILL, so use SIGTERM instead
621+
sig = getattr(signal, 'SIGKILL', signal.SIGTERM)
622+
os.kill(pid, sig)
621623
for child_pid in child_pids:
622624
try:
623-
os.kill(child_pid, SIGKILL)
625+
os.kill(child_pid, sig)
624626
except OSError:
625627
pass
626628
kill_check.set() # tell the main routine that the process was killed

0 commit comments

Comments
 (0)