ssh kitten: Fix restore state not being called after interrupt

This commit is contained in:
Kovid Goyal 2023-11-05 08:38:04 +05:30
parent 995112d952
commit bc1da5525e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -731,9 +731,12 @@ func run_ssh(ssh_args, server_args, found_extra_args []string) (rc int, err erro
if escape_codes_to_set_colors != "" {
restore_escape_codes += "\x1b[#Q"
}
sigs := make(chan os.Signal, 8)
signal.Notify(sigs, unix.SIGINT, unix.SIGTERM)
defer func() {
_ = term.WriteAllString(restore_escape_codes)
term.RestoreAndClose()
signal.Reset()
}()
err = get_remote_command(&cd)
if err != nil {
@ -746,8 +749,6 @@ 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"])
@ -772,7 +773,6 @@ func run_ssh(ssh_args, server_args, found_extra_args []string) (rc int, err erro
}()
err = c.Wait()
drain_potential_tty_garbage(term)
signal.Reset(unix.SIGINT, unix.SIGTERM)
if err != nil {
var exit_err *exec.ExitError
if errors.As(err, &exit_err) {