From 449495ca42f428a038dfd6fdd5b657d6df83fead Mon Sep 17 00:00:00 2001 From: Michael L Heuer Date: Fri, 31 May 2024 09:28:14 -0500 Subject: [PATCH] install sigpipe signal handler --- src/main/java/com/github/heuermh/cooper/Cooper.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/github/heuermh/cooper/Cooper.java b/src/main/java/com/github/heuermh/cooper/Cooper.java index cc27d56..797f836 100644 --- a/src/main/java/com/github/heuermh/cooper/Cooper.java +++ b/src/main/java/com/github/heuermh/cooper/Cooper.java @@ -161,6 +161,14 @@ public static void main(final String[] args) { } logger = LoggerFactory.getLogger(Cooper.class); + // install a signal handler to exit on SIGPIPE + sun.misc.Signal.handle(new sun.misc.Signal("PIPE"), new sun.misc.SignalHandler() { + @Override + public void handle(final sun.misc.Signal signal) { + System.exit(0); + } + }); + System.exit(new CommandLine(new Cooper()).execute(args)); } }