fix: handle sigterm and remove obsolete code

fg-job
TorchedSammy 2022-05-21 20:53:02 -04:00
parent 0b07b93de2
commit 392cb66382
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 4 additions and 11 deletions

View File

@ -10,20 +10,13 @@ import (
func handleSignals() { func handleSignals() {
c := make(chan os.Signal) c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGWINCH, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGQUIT) signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGWINCH, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGQUIT)
for s := range c { for s := range c {
switch s { switch s {
case os.Interrupt: case os.Interrupt: hooks.Em.Emit("signal.sigint")
hooks.Em.Emit("signal.sigint") case syscall.SIGTERM: exit(0)
if !running && interactive { case syscall.SIGWINCH: hooks.Em.Emit("signal.resize")
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.SIGUSR1: hooks.Em.Emit("signal.sigusr1")
case syscall.SIGUSR2: hooks.Em.Emit("signal.sigusr2") case syscall.SIGUSR2: hooks.Em.Emit("signal.sigusr2")
} }