ssh kitten: Fix a regression in 0.28.0 that caused interrupt during setup to not be handled gracefully

Fixes #6254
This commit is contained in:
Kovid Goyal 2023-05-08 16:18:05 +05:30
parent 71189aee9f
commit 454acd4f5c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 0 deletions

View File

@ -59,6 +59,8 @@ Detailed list of changes
- edit-in-kitty: Fix running edit-in-kitty with elevated privileges to edit a restricted file not working (:disc:`6245`) - edit-in-kitty: Fix running edit-in-kitty with elevated privileges to edit a restricted file not working (:disc:`6245`)
- ssh kitten: Fix a regression in 0.28.0 that caused interrupt during setup to not be handled gracefully (:iss:`6254`)
0.28.1 [2023-04-21] 0.28.1 [2023-04-21]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -16,6 +16,7 @@ import (
"net/url" "net/url"
"os" "os"
"os/exec" "os/exec"
"os/signal"
"os/user" "os/user"
"path" "path"
"path/filepath" "path/filepath"
@ -669,6 +670,9 @@ func run_ssh(ssh_args, server_args, found_extra_args []string) (rc int, err erro
if err != nil { if err != nil {
return 1, err return 1, err
} }
sigs := make(chan os.Signal, 8)
signal.Notify(sigs, unix.SIGINT, unix.SIGTERM)
if !cd.request_data { if !cd.request_data {
rq := fmt.Sprintf("id=%s:pwfile=%s:pw=%s", cd.replacements["REQUEST_ID"], cd.replacements["PASSWORD_FILENAME"], cd.replacements["DATA_PASSWORD"]) rq := fmt.Sprintf("id=%s:pwfile=%s:pw=%s", cd.replacements["REQUEST_ID"], cd.replacements["PASSWORD_FILENAME"], cd.replacements["DATA_PASSWORD"])
err := term.ApplyOperations(tty.TCSANOW, tty.SetNoEcho) err := term.ApplyOperations(tty.TCSANOW, tty.SetNoEcho)
@ -685,6 +689,11 @@ func run_ssh(ssh_args, server_args, found_extra_args []string) (rc int, err erro
return 1, err return 1, err
} }
} }
go func() {
_ = <-sigs
// ignore any interrupt and terminate signals as they will usually be sent to the ssh child process as well
// and we are waiting on that.
}()
err = c.Wait() err = c.Wait()
drain_potential_tty_garbage(term) drain_potential_tty_garbage(term)
if err != nil { if err != nil {