changeset 29370:3ddf4d0c4170

chg: ignore SIGINT while waiting pager termination Otherwise the terminal would be left with unclean state. This is what fcc4b55876c3 does.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 15 Jun 2016 23:49:56 +0900
parents 85a18f3c0bdd
children 1b699c7eb2b7
files contrib/chg/chg.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/chg/chg.c	Wed Jun 15 23:32:00 2016 +0900
+++ b/contrib/chg/chg.c	Wed Jun 15 23:49:56 2016 +0900
@@ -434,8 +434,6 @@
 
 	if (sigaction(SIGHUP, &sa, NULL) < 0)
 		goto error;
-	if (sigaction(SIGINT, &sa, NULL) < 0)
-		goto error;
 	if (sigaction(SIGTERM, &sa, NULL) < 0)
 		goto error;
 	if (sigaction(SIGWINCH, &sa, NULL) < 0)
@@ -445,6 +443,11 @@
 	if (sigaction(SIGTSTP, &sa, NULL) < 0)
 		goto error;
 
+	/* ignore Ctrl+C while shutting down to make pager exits cleanly */
+	sa.sa_handler = SIG_IGN;
+	if (sigaction(SIGINT, &sa, NULL) < 0)
+		goto error;
+
 	peerpid = 0;
 	return;