Description
Setup
- Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.36.1.windows.1
cpu: x86_64
built from commit: e2ff68a2d1426758c78d023f863bfa1e03cbc768
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
- Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.19044.1645]
- What options did you set as part of the installation? Or did you choose the
defaults?
$ cat /etc/install-options.txt
Editor Option: Notepad++
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: LFOnly
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled
- Any other interesting things about your environment that might be related
to the issue you're seeing?
No
Details
When running an SSH command, hitting CTRL-C sends SIGINT to the remote process instead of terminating the SSH command, as expected. However, in 2.36.1.windows.1
, if you sent at least one CTRL-C during an SSH session, then, once the SSH session ends but before the SSH command terminates, the SSH command will receive an interrupt:
REDACTED@REDACTED MINGW64 ~
$ ssh dev
Last login: Tue May 10 16:42:30 2022 from 10.0.132.5
[foo@bar-dev-12 ~ DEV12 ]
$ ^C
[foo@bar-dev-12 ~ DEV12 ]
$ ^C
[foo@bar-dev-12 ~ DEV12 ]
$
[foo@bar-dev-12 ~ DEV12 ]
$ exit
logout
Connection to 10.0.25.209 closed.
Traceback (most recent call last):
File "C:/Users/REDACTED/source/ssh-wrappy.git/bin/ssh", line 358, in <module>
res = main()
File "C:/Users/REDACTED/source/ssh-wrappy.git/bin/ssh", line 350, in main
ret = subprocess.call(cmd)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 325, in call
return p.wait(timeout=timeout)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 990, in wait
return self._wait(timeout=timeout)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1230, in _wait
timeout_millis)
KeyboardInterrupt
REDACTED@REDACTED MINGW64 ~
$ echo $?
1
Note: ssh-wrappy.git/bin/ssh
is a Python wrapper around ssh.exe
which we use to automatically translate certain server names into their addresses. dev
, however, is not one of those special servers.
If CTRL-C is not used during the SSH session, it terminates cleanly instead:
REDACTED@REDACTED MINGW64 ~
$ ssh dev
Last login: Tue May 10 16:42:59 2022 from 10.0.132.5
[foo@bar-dev-12 ~ DEV12 ]
$ exit
logout
Connection to 10.0.25.209 closed.
REDACTED@REDACTED MINGW64 ~
$ echo $?
0
If I bypass the wrapper script, the same thing happens, just less obviously without Python's exception traceback:
REDACTED@REDACTED MINGW64 ~
$ /bin/ssh dev
Last login: Tue May 10 16:46:01 2022 from 10.0.132.5
[foo@bar-dev-12 ~ DEV12 ]
$ ^C
[foo@bar-dev-12 ~ DEV12 ]
$ exit
logout
Connection to 10.0.25.209 closed.
REDACTED@REDACTED MINGW64 ~
$ echo $?
130
REDACTED@REDACTED MINGW64 ~
$ /bin/ssh dev
Last login: Tue May 10 16:50:21 2022 from 10.0.132.5
[foo@bar-dev-12 ~ DEV12 ]
$ exit
logout
Connection to 10.0.25.209 closed.
REDACTED@REDACTED MINGW64 ~
$ echo $?
0
- What did you expect to occur after running these commands?
CTRL-C sent to SSH should affect only the remote command.
- What actually happened instead?
CTRL-C affected both the remote command & the SSH command.
Notes
2.34.1
behaved correctly - CTRL-C affected only the remote command- Just reinstalled
2.34.1.windows.1
and tested this. While the Python script doesn't produce aKeyboardInterrupt
, if I run SSH directly, I still get exit code 130.
- Just reinstalled
2.36.0.rc0.windows.1
had a similar but worse bug where CTRL-C during an SSH session would immediately kill the SSH command ( ctrl+c in gitbash on windows terminal kills ssh remote sessions microsoft/terminal#12431 )