Skip to content

Commit aa41689

Browse files
committed
ps workaround
1 parent e1dd1ec commit aa41689

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

tools/indirect-run.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
& "C:\Program Files\Git\bin\bash.EXE" "tools/test-interrupt.sh"
4+
5+
# Write-Host "Starting"
6+
# $proc = Start-Process -FilePath "C:\Program Files\Git\bin\bash.EXE" -ArgumentList @("tools/test-interrupt.sh") -Wait -PassThru
7+
# $result = $proc.ExitCode
8+
# Write-Host "Wrapper Finishing with $result"
9+
# Exit $result

tools/run-with-console.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
import threading
55
import signal
66
from typing import TextIO
7+
import ctypes
78

89
def stream_output(stream: TextIO, output_stream: TextIO):
910
for line in iter(stream.readline, ''):
1011
output_stream.write(line)
1112
output_stream.flush()
1213
stream.close()
1314

15+
result = ctypes.windll.kernel32.SetConsoleCtrlHandler(None, 0)
16+
if not result:
17+
print(f"SetConsoleCtrlHandler restore failed")
18+
1419
process = subprocess.Popen(
15-
["C:\\Program Files\\Git\\bin\\bash.EXE", "tools/test-interrupt.sh"],
20+
# ["C:\\Program Files\\Git\\bin\\bash.EXE", "tools/test-interrupt.sh"],
21+
["powershell.exe", "tools/indirect-run.ps1"],
1622
creationflags=subprocess.CREATE_NEW_CONSOLE|subprocess.CREATE_NEW_PROCESS_GROUP|subprocess.CREATE_NO_WINDOW,
1723
stdout=subprocess.PIPE,
1824
stderr=subprocess.PIPE,
@@ -29,10 +35,8 @@ def stream_output(stream: TextIO, output_stream: TextIO):
2935

3036
# Poll the process instead of blocking wait
3137
try:
32-
print("Polling")
3338
returncode = process.wait()
3439
except KeyboardInterrupt:
35-
print("Terminating")
3640
process.terminate()
3741
returncode = 1
3842
# break

0 commit comments

Comments
 (0)