pager: don't terminate with extreme prejudice on SIGPIPE (BC)
authorSimon Farnsworth <simonfar@fb.com>
Thu, 02 Feb 2017 11:17:36 -0800
changeset 30867 aaa751585325
parent 30866 5249b6470de9
child 30868 847f06179f60
pager: don't terminate with extreme prejudice on SIGPIPE (BC) The default SIGPIPE handler causes Mercurial to exit immediately, without running any Python cleanup code (except and finally blocks, atexit handlers etc). This creates problems if you want to do something at exit. If we need a different exit code for broken pipe from pager, then we should code that ourselves in Python; this appears to have been cargo-culted from the fork implementation of pager that's no longer used, where it was needed to stop Broken Pipe errors appearing on the user's terminal.
hgext/pager.py
--- a/hgext/pager.py	Mon Jan 23 10:48:55 2017 -0800
+++ b/hgext/pager.py	Thu Feb 02 11:17:36 2017 -0800
@@ -153,8 +153,6 @@
         if usepager:
             ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
             ui.setconfig('ui', 'interactive', False, 'pager')
-            if util.safehasattr(signal, "SIGPIPE"):
-                signal.signal(signal.SIGPIPE, signal.SIG_DFL)
             ui._runpager(p)
         return orig(ui, options, cmd, cmdfunc)