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
2 changed files with 11 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import (
"net/url"
"os"
"os/exec"
"os/signal"
"os/user"
"path"
"path/filepath"
@@ -669,6 +670,9 @@ func run_ssh(ssh_args, server_args, found_extra_args []string) (rc int, err erro
if err != nil {
return 1, err
}
sigs := make(chan os.Signal, 8)
signal.Notify(sigs, unix.SIGINT, unix.SIGTERM)
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"])
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
}
}
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()
drain_potential_tty_garbage(term)
if err != nil {