From 5184859c54495bcc7a498836ed483a9788a0c5d0 Mon Sep 17 00:00:00 2001 From: akulij Date: Thu, 27 Feb 2025 22:18:18 +0000 Subject: [PATCH] handle sigpipe for user friendliness --- cmd/age-passgen/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/age-passgen/main.go b/cmd/age-passgen/main.go index 61da44f..225571e 100644 --- a/cmd/age-passgen/main.go +++ b/cmd/age-passgen/main.go @@ -101,6 +101,18 @@ func main() { } 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) {