2024-06-09 09:35:16 +00:00
|
|
|
// +build unix
|
2022-02-28 20:15:08 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
)
|
|
|
|
|
|
|
|
func handleSignals() {
|
|
|
|
c := make(chan os.Signal)
|
2022-05-24 23:15:02 +00:00
|
|
|
signal.Ignore(syscall.SIGTTOU, syscall.SIGTTIN, syscall.SIGTSTP)
|
2022-05-22 00:53:02 +00:00
|
|
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGWINCH, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGQUIT)
|
2022-02-28 20:15:08 +00:00
|
|
|
|
|
|
|
for s := range c {
|
|
|
|
switch s {
|
2022-08-17 22:01:32 +00:00
|
|
|
case os.Interrupt: hooks.Emit("signal.sigint")
|
2022-05-22 00:53:02 +00:00
|
|
|
case syscall.SIGTERM: exit(0)
|
2022-08-17 22:01:32 +00:00
|
|
|
case syscall.SIGWINCH: hooks.Emit("signal.resize")
|
|
|
|
case syscall.SIGUSR1: hooks.Emit("signal.sigusr1")
|
|
|
|
case syscall.SIGUSR2: hooks.Emit("signal.sigusr2")
|
2022-02-28 20:15:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|