2022-02-28 20:15:08 +00:00
|
|
|
// +build darwin linux
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
)
|
|
|
|
|
|
|
|
func handleSignals() {
|
|
|
|
c := make(chan os.Signal)
|
2022-03-15 00:55:00 +00:00
|
|
|
signal.Notify(c, os.Interrupt, syscall.SIGWINCH, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGQUIT)
|
2022-02-28 20:15:08 +00:00
|
|
|
|
|
|
|
for s := range c {
|
|
|
|
switch s {
|
|
|
|
case os.Interrupt:
|
|
|
|
hooks.Em.Emit("signal.sigint")
|
|
|
|
if !running && interactive {
|
|
|
|
lr.ClearInput()
|
|
|
|
}
|
|
|
|
case syscall.SIGWINCH:
|
|
|
|
hooks.Em.Emit("signal.resize")
|
|
|
|
if !running && interactive {
|
|
|
|
lr.Resize()
|
|
|
|
}
|
|
|
|
case syscall.SIGUSR1: hooks.Em.Emit("signal.sigusr1")
|
|
|
|
case syscall.SIGUSR2: hooks.Em.Emit("signal.sigusr2")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|