Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f017ac

Browse files
committed
Avoid making it look like kill_process works on Windows
This changes the code in Git.execute's local kill_process function,which it uses as the timed callback for kill_after_timeout, toremove code that is unnecessary because kill_process doesn'tsupport Windows, and to avoid giving the false impression that itscode could be used unmodified on Windows without serious problems.- Raise AssertionError explicitly if it is called on Windows. This is done with "raise" rather than "assert" so its behavior doesn't vary depending on "-O".- Don't pass process creation flags, because they were 0 except on Windows.- Don't fall back to SIGTERM if Python's signal module doesn't know about SIGKILL. This was specifically for Windows which has no SIGKILL.See#1756 for discussion.
1 parentf42a63b commit2f017ac

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

‎git/cmd.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,9 @@ def execute(
10151015

10161016
defkill_process(pid:int)->None:
10171017
"""Callback to kill a process."""
1018-
p=Popen(
1019-
["ps","--ppid",str(pid)],
1020-
stdout=PIPE,
1021-
creationflags=PROC_CREATIONFLAGS,
1022-
)
1018+
ifos.name=="nt":
1019+
raiseAssertionError("Bug: This callback would be ineffective and unsafe on Windows, stopping.")
1020+
p=Popen(["ps","--ppid",str(pid)],stdout=PIPE)
10231021
child_pids= []
10241022
ifp.stdoutisnotNone:
10251023
forlineinp.stdout:
@@ -1028,18 +1026,16 @@ def kill_process(pid: int) -> None:
10281026
iflocal_pid.isdigit():
10291027
child_pids.append(int(local_pid))
10301028
try:
1031-
# Windows does not have SIGKILL, so use SIGTERM instead.
1032-
sig=getattr(signal,"SIGKILL",signal.SIGTERM)
1033-
os.kill(pid,sig)
1029+
os.kill(pid,signal.SIGKILL)
10341030
forchild_pidinchild_pids:
10351031
try:
1036-
os.kill(child_pid,sig)
1032+
os.kill(child_pid,signal.SIGKILL)
10371033
exceptOSError:
10381034
pass
10391035
kill_check.set()# Tell the main routine that the process was killed.
10401036
exceptOSError:
1041-
# It is possible that the process gets completed in the duration after timeout
1042-
# happens and before we try to kill the process.
1037+
# It is possible that the process gets completed in the duration after
1038+
#timeouthappens and before we try to kill the process.
10431039
pass
10441040
return
10451041

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp