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

login
register
mail settings
Submitter Yuya Nishihara
Date June 15, 2016, 3:17 p.m.
Message ID <889b2b89ecc26c8c00f3.1466003829@mimosa>
Download mbox | patch
Permalink /patch/15524/
State Accepted
Headers show

Comments

Yuya Nishihara - June 15, 2016, 3:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Jun Wu - June 15, 2016, 4:20 p.m.
These 2 patches look good to me.

Excerpts from Yuya Nishihara's message of 2016-06-16 00:17:09 +0900:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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;
>
Matt Mackall - June 16, 2016, 10:16 p.m.
On Thu, 2016-06-16 at 00:17 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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

These are queued, thanks.
-- 
Mathematics is the supreme nostalgia of our time.

Patch

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;