Patchwork crecord: fix issue when backgrounding editor would leave artefact

mail settings
Submitter Laurent Charignon
Date July 16, 2015, 7:03 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/10021/
State Accepted
Commit 2cccaf937a7a37de68f50c07cd7190cb53cf947d
Headers show


Laurent Charignon - July 16, 2015, 7:03 p.m.
# HG changeset patch
# User Laurent Charignon <<>>
# Date 1437017963 25200
#      Wed Jul 15 20:39:23 2015 -0700
# Node ID aacc79aaf710f69c3e060920bcf3255d88640a87
# Parent  35fa7c77c754aa4d156c42abfdb61ca178468872
crecord: fix issue when backgrounding editor would leave artefact

Before this patch:
- if a user was entering a commit message after having ran the curses
- and then uses ctrl-z, followed by fg to put the editor in the
- then the curses interface would leave artefact on the screen of
the editor, making entering the commit message a difficult task

This happened because ncurses registers a signal handler for SIGTSTP and
does not restore the original signal handler after running.
More info at:<

This patch restores the original value of the signal handler after
running the curses interface and therefore fixes this issue.
It don't know how to add a test for this issue, I tested the scenario
above manually and it works correctly with the patch.


diff -r 35fa7c77c754 -r aacc79aaf710 mercurial/
--- a/mercurial/ Sun Jul 12 17:59:25 2015 +0900
+++ b/mercurial/ Wed Jul 15 20:39:23 2015 -0700
@@ -482,7 +482,10 @@ 
    ui.write(_('starting interactive selection\n'))
    chunkselector = curseschunkselector(headerlist, ui)
+    f = signal.getsignal(signal.SIGTSTP)
+    # ncurses does not restore signal handler for SIGTSTP
+    signal.signal(signal.SIGTSTP, f)

def testdecorator(testfn, f):
    def u(*args, **kwargs):