mirror of
https://github.com/zyedidia/micro.git
synced 2024-08-16 15:30:37 +03:00
Move sigterm channel to internal/util
This commit is contained in:
parent
9eb8782ff2
commit
26ae1b95cc
@ -40,7 +40,6 @@ var (
|
|||||||
flagClean = flag.Bool("clean", false, "Clean configuration directory")
|
flagClean = flag.Bool("clean", false, "Clean configuration directory")
|
||||||
optionFlags map[string]*string
|
optionFlags map[string]*string
|
||||||
|
|
||||||
sigterm chan os.Signal
|
|
||||||
sighup chan os.Signal
|
sighup chan os.Signal
|
||||||
|
|
||||||
timerChan chan func()
|
timerChan chan func()
|
||||||
@ -360,9 +359,9 @@ func main() {
|
|||||||
|
|
||||||
screen.Events = make(chan tcell.Event)
|
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)
|
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)
|
signal.Notify(sighup, syscall.SIGHUP)
|
||||||
|
|
||||||
timerChan = make(chan func())
|
timerChan = make(chan func())
|
||||||
@ -437,7 +436,7 @@ func DoEvent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
case <-sigterm:
|
case <-util.Sigterm:
|
||||||
for _, b := range buffer.OpenBuffers {
|
for _, b := range buffer.OpenBuffers {
|
||||||
if !b.Modified() {
|
if !b.Modified() {
|
||||||
b.Fini()
|
b.Fini()
|
||||||
|
@ -41,6 +41,8 @@ var (
|
|||||||
|
|
||||||
// Stdout is a buffer that is written to stdout when micro closes
|
// Stdout is a buffer that is written to stdout when micro closes
|
||||||
Stdout *bytes.Buffer
|
Stdout *bytes.Buffer
|
||||||
|
// Sigterm is a channel where micro exits when written
|
||||||
|
Sigterm chan os.Signal
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user