From b7fbb3cb2550841d5593535e73d8b8c1de18ebee Mon Sep 17 00:00:00 2001
From: cnlohr <lohr85@gmail.com>
Date: Fri, 30 Jun 2023 18:06:01 -0400
Subject: [PATCH] Make sigpipe exit cleanly.

---
 minichlink/terminalhelp.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/minichlink/terminalhelp.h b/minichlink/terminalhelp.h
index 38cbcf1..65def66 100644
--- a/minichlink/terminalhelp.h
+++ b/minichlink/terminalhelp.h
@@ -96,6 +96,8 @@ static int ReadKBByte()
 
 static void CtrlC()
 {
+	fprintf( stderr, "Minichlink Closing\n" );
+	ResetKeyboardInput();
 	exit( 0 );
 }
 
@@ -105,6 +107,7 @@ static void CaptureKeyboardInput()
 	// Hook exit, because we want to re-enable keyboard.
 	atexit(ResetKeyboardInput);
 	signal(SIGINT, CtrlC);
+	signal(SIGPIPE, CtrlC);
 
 	struct termios term;
 	tcgetattr(0, &term);
-- 
GitLab