[PATCH 2 of 2] chg: ignore SIGINT while waiting pager termination

Yuya Nishihara yuya at tcha.org
Wed Jun 15 11:17:09 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1466002196 -32400
#      Wed Jun 15 23:49:56 2016 +0900
# Node ID 889b2b89ecc26c8c00f3d2487ad02a52337c92e1
# Parent  3cf2517e5c15dcc0fc9c433350514c3e25e4f737
chg: ignore SIGINT while waiting pager termination

Otherwise the terminal would be left with unclean state. This is what
fcc4b55876c3 does.

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -434,8 +434,6 @@ static void restoresignalhandler()
 
 	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 @@ static void restoresignalhandler()
 	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;
 


More information about the Mercurial-devel mailing list