sigpipe signal processing

This commit is contained in:
ulricqin 2022-05-12 17:01:00 +08:00 committed by GitHub
commit b6594afdda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}