[PATCH 1 of 6 v2] pager: don't terminate with extreme prejudice on SIGPIPE (BC)

Simon Farnsworth simonfar at fb.com
Thu Feb 2 19:18:55 UTC 2017


# HG changeset patch
# User Simon Farnsworth <simonfar at fb.com>
# Date 1486063056 28800
#      Thu Feb 02 11:17:36 2017 -0800
# Node ID f443bd95a948aaed36e81edb884085fc2f0f5acf
# Parent  abf029200e198878a4576a87e095bd8d77d9cea9
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.

diff --git a/hgext/pager.py b/hgext/pager.py
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -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)
 


More information about the Mercurial-devel mailing list