1
0
mirror of https://github.com/zyedidia/micro synced 2024-07-01 06:54:31 +00:00

Move sigterm channel to internal/util

This commit is contained in:
niten94 2024-06-17 15:11:13 +08:00
parent 9eb8782ff2
commit 26ae1b95cc
2 changed files with 6 additions and 5 deletions

View File

@ -40,8 +40,7 @@ var (
flagClean = flag.Bool("clean", false, "Clean configuration directory")
optionFlags map[string]*string
sigterm chan os.Signal
sighup chan os.Signal
sighup chan os.Signal
timerChan chan func()
)
@ -360,9 +359,9 @@ func main() {
screen.Events = make(chan tcell.Event)
sigterm = make(chan os.Signal, 1)
util.Sigterm = make(chan os.Signal, 1)
sighup = make(chan os.Signal, 1)
signal.Notify(sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGABRT)
signal.Notify(util.Sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGABRT)
signal.Notify(sighup, syscall.SIGHUP)
timerChan = make(chan func())
@ -437,7 +436,7 @@ func DoEvent() {
}
}
os.Exit(0)
case <-sigterm:
case <-util.Sigterm:
for _, b := range buffer.OpenBuffers {
if !b.Modified() {
b.Fini()

View File

@ -41,6 +41,8 @@ var (
// Stdout is a buffer that is written to stdout when micro closes
Stdout *bytes.Buffer
// Sigterm is a channel where micro exits when written
Sigterm chan os.Signal
)
func init() {