sigpipe signal processing

This commit is contained in:
kongfei 2022-05-12 10:56:59 +08:00
parent 66aae2ec39
commit 119236dc4a
2 changed files with 6 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
.idea
.vscode
/categraf*
*.log

View File

@ -55,7 +55,7 @@ func main() {
func handleSignal(ag *agent.Agent) {
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
signal.Notify(sc, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGPIPE)
EXIT:
for {
@ -66,6 +66,9 @@ EXIT:
break EXIT
case syscall.SIGHUP:
ag.Reload()
case syscall.SIGPIPE:
// https://pkg.go.dev/os/signal#hdr-SIGPIPE
// do nothing
default:
break EXIT
}