handle sigpipe for user friendliness

This commit is contained in:
akulij 2025-02-27 22:18:18 +00:00
parent bd018136d6
commit 5184859c54

View File

@ -101,6 +101,18 @@ func main() {
} }
func setSystemSignalHandlers() { func setSystemSignalHandlers() {
go handleSigpipe()
}
func handleSigpipe() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGPIPE)
<-c
errorf("Recieved SIGPIPE. Check if your programs that give input or recieve input do not stops before this one")
os.Exit(1)
} }
func parseFlags() (*Flags, error) { func parseFlags() (*Flags, error) {