VictoriaMetrics/lib/procutil/signal.go

17 lines
276 B
Go
Raw Normal View History

2019-05-22 23:16:55 +02:00
package procutil
import (
"os"
"os/signal"
"syscall"
)
// WaitForSigterm waits for either SIGTERM or SIGINT
2019-05-22 23:16:55 +02:00
//
// Returns the caught signal.
func WaitForSigterm() os.Signal {
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
return <-ch
}