diff --git a/docs/changelog.rst b/docs/changelog.rst index bfee3f786..cb991988e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -130,6 +130,8 @@ Detailed list of changes - Fix a regression in 0.40.0 that broke serialization of tab characters as ANSI text (:iss:`8741`) +- kitten run-shell: Fix SIGINT blocked when execing the shell (:iss:`8754`) + 0.42.1 [2025-05-17] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tools/tui/run.go b/tools/tui/run.go index ba53634e0..500fe2370 100644 --- a/tools/tui/run.go +++ b/tools/tui/run.go @@ -142,10 +142,8 @@ func rc_modification_allowed(ksi string) (allowed bool, set_ksi_env_var bool) { case "disabled": allowed = false set_ksi_env_var = false - break case "no-rc": allowed = false - break } } return @@ -232,17 +230,17 @@ func RunCommandRestoringTerminalToSaneStateAfter(cmd []string) { defer term.Close() } } - func() { - if err = c.Start(); err != nil { - fmt.Fprintln(os.Stderr, cmd[0], "failed to start with error:", err) - return - } - // Ignore SIGINT as the kernel tends to send it to us as well as the - // subprocess on Ctrl+C - signal.Ignore(os.Interrupt) - defer signal.Reset(os.Interrupt) - err = c.Wait() - }() + // Ignore SIGINT as the kernel tends to send it to us as well as the + // subprocess on Ctrl+C. We cant use signal.Ignore as it doesnt reset + // sigprocmask so subsequent unix.Exec will inherit blocked SIGINT + ignore_sigint_channel := make(chan os.Signal, 512) + if err = c.Start(); err != nil { + fmt.Fprintln(os.Stderr, cmd[0], "failed to start with error:", err) + return + } + signal.Notify(ignore_sigint_channel, os.Interrupt) + err = c.Wait() + signal.Reset(os.Interrupt) if err != nil { fmt.Fprintln(os.Stderr, cmd[0], "failed with error:", err) }