mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 06:30:28 +09:00
Receive SIGINT only in RunInteractiveShell
Temporarily reset SIGINT signal handlers and receive SIGINT in RunInteractiveShell. Do not try to kill the process in micro when signal is received.
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
shellquote "github.com/kballard/go-shellquote"
|
||||
"github.com/zyedidia/micro/v2/internal/screen"
|
||||
"github.com/zyedidia/micro/v2/internal/util"
|
||||
)
|
||||
|
||||
// ExecCommand executes a command using exec
|
||||
@@ -95,15 +96,11 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
// This is a trap for Ctrl-C so that it doesn't kill micro
|
||||
// Instead we trap Ctrl-C to kill the program we're running
|
||||
// micro is killed if the signal is ignored only on Windows, so it is
|
||||
// received
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Reset(os.Interrupt)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func() {
|
||||
for range c {
|
||||
cmd.Process.Kill()
|
||||
}
|
||||
}()
|
||||
|
||||
cmd.Start()
|
||||
err = cmd.Wait()
|
||||
|
||||
@@ -117,6 +114,9 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error
|
||||
// Start the screen back up
|
||||
screen.TempStart(screenb)
|
||||
|
||||
signal.Notify(util.Sigterm, os.Interrupt)
|
||||
signal.Stop(c)
|
||||
|
||||
return output, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user