Patchwork [4,of,5,STABLE] crecord: ensure we reinstall the SIGSTOP handler

login
register
mail settings
Submitter Pierre-Yves David
Date April 12, 2017, 8:41 a.m.
Message ID <f83025d451fa293849f8.1491986479@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20129/
State Accepted
Headers show

Comments

Pierre-Yves David - April 12, 2017, 8:41 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1491470713 -7200
#      Thu Apr 06 11:25:13 2017 +0200
# Branch stable
# Node ID f83025d451fa293849f819cc997bc3f8c9ce42e0
# Parent  7c33ce6b8a6991d4189c7d379a78a2c2fa802c35
# EXP-Topic crecord-windows
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r f83025d451fa
crecord: ensure we reinstall the SIGSTOP handler

Previous, exceptions would prevent the reinstallation of the
signal.
Augie Fackler - April 12, 2017, 8:46 p.m.
On Wed, Apr 12, 2017 at 10:41:19AM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1491470713 -7200
> #      Thu Apr 06 11:25:13 2017 +0200
> # Branch stable
> # Node ID f83025d451fa293849f819cc997bc3f8c9ce42e0
> # Parent  7c33ce6b8a6991d4189c7d379a78a2c2fa802c35
> # EXP-Topic crecord-windows
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r f83025d451fa
> crecord: ensure we reinstall the SIGSTOP handler

Up here you said "SIGSTOP"...

>
> Previous, exceptions would prevent the reinstallation of the
> signal.
>
> diff --git a/mercurial/crecord.py b/mercurial/crecord.py
> --- a/mercurial/crecord.py
> +++ b/mercurial/crecord.py
> @@ -474,11 +474,13 @@ def chunkselector(ui, headerlist, operat
>      ui.write(_('starting interactive selection\n'))
>      chunkselector = curseschunkselector(headerlist, ui, operation)
>      f = signal.getsignal(signal.SIGTSTP)
> -    curses.wrapper(chunkselector.main)
> -    if chunkselector.initerr is not None:
> -        raise error.Abort(chunkselector.initerr)
> -    # ncurses does not restore signal handler for SIGTSTP
> -    signal.signal(signal.SIGTSTP, f)

But down here it says SIGTSTP. Typo in the log message above?

> +    try:
> +        curses.wrapper(chunkselector.main)
> +        if chunkselector.initerr is not None:
> +            raise error.Abort(chunkselector.initerr)
> +        # ncurses does not restore signal handler for SIGTSTP
> +    finally:
> +        signal.signal(signal.SIGTSTP, f)
>      return chunkselector.opts
>
>  def testdecorator(testfn, f):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Pierre-Yves David - April 12, 2017, 8:48 p.m.
On 04/12/2017 10:46 PM, Augie Fackler wrote:
> On Wed, Apr 12, 2017 at 10:41:19AM +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
>> # Date 1491470713 -7200
>> #      Thu Apr 06 11:25:13 2017 +0200
>> # Branch stable
>> # Node ID f83025d451fa293849f819cc997bc3f8c9ce42e0
>> # Parent  7c33ce6b8a6991d4189c7d379a78a2c2fa802c35
>> # EXP-Topic crecord-windows
>> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r f83025d451fa
>> crecord: ensure we reinstall the SIGSTOP handler
>
> Up here you said "SIGSTOP"...

Should be SIGTSTP

>
>>
>> Previous, exceptions would prevent the reinstallation of the
>> signal.
>>
>> diff --git a/mercurial/crecord.py b/mercurial/crecord.py
>> --- a/mercurial/crecord.py
>> +++ b/mercurial/crecord.py
>> @@ -474,11 +474,13 @@ def chunkselector(ui, headerlist, operat
>>      ui.write(_('starting interactive selection\n'))
>>      chunkselector = curseschunkselector(headerlist, ui, operation)
>>      f = signal.getsignal(signal.SIGTSTP)
>> -    curses.wrapper(chunkselector.main)
>> -    if chunkselector.initerr is not None:
>> -        raise error.Abort(chunkselector.initerr)
>> -    # ncurses does not restore signal handler for SIGTSTP
>> -    signal.signal(signal.SIGTSTP, f)
>
> But down here it says SIGTSTP. Typo in the log message above?

yeah, my bad.

>
>> +    try:
>> +        curses.wrapper(chunkselector.main)
>> +        if chunkselector.initerr is not None:
>> +            raise error.Abort(chunkselector.initerr)
>> +        # ncurses does not restore signal handler for SIGTSTP
>> +    finally:
>> +        signal.signal(signal.SIGTSTP, f)
>>      return chunkselector.opts
>>
>>  def testdecorator(testfn, f):
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -474,11 +474,13 @@  def chunkselector(ui, headerlist, operat
     ui.write(_('starting interactive selection\n'))
     chunkselector = curseschunkselector(headerlist, ui, operation)
     f = signal.getsignal(signal.SIGTSTP)
-    curses.wrapper(chunkselector.main)
-    if chunkselector.initerr is not None:
-        raise error.Abort(chunkselector.initerr)
-    # ncurses does not restore signal handler for SIGTSTP
-    signal.signal(signal.SIGTSTP, f)
+    try:
+        curses.wrapper(chunkselector.main)
+        if chunkselector.initerr is not None:
+            raise error.Abort(chunkselector.initerr)
+        # ncurses does not restore signal handler for SIGTSTP
+    finally:
+        signal.signal(signal.SIGTSTP, f)
     return chunkselector.opts
 
 def testdecorator(testfn, f):