# HG changeset patch # User Simon Farnsworth # Date 1486568650 28800 # Node ID 253d5c0f3a2f424b5f941cca0f788d2bed819452 # Parent b9116befa78417b1cb3763dafd44cc1fc6952109 pager: exit cleanly on SIGPIPE (BC) Changeset aaa751585325 removes SIGPIPE handling completely. This is wrong, as it means that Mercurial does not exit when the pager does. Instead, raise SignalInterrupt when SIGPIPE happens with a pager attached, to trigger the normal exit path. This will cause "killed!" to be printed to stderr (hence the BC warning), but in the normal pager use case (where the pager gets both stderr and stdout), this message is lost as we only get SIGPIPE when the pager quits. diff -r b9116befa784 -r 253d5c0f3a2f hgext/pager.py --- a/hgext/pager.py Fri Feb 10 04:09:06 2017 -0800 +++ b/hgext/pager.py Wed Feb 08 07:44:10 2017 -0800 @@ -72,6 +72,7 @@ commands, dispatch, encoding, + error, extensions, util, ) @@ -105,6 +106,9 @@ pager.stdin.close() pager.wait() +def catchterm(*args): + raise error.SignalInterrupt + def uisetup(ui): class pagerui(ui.__class__): def _runpager(self, pagercmd): @@ -144,6 +148,8 @@ if usepager: ui.setconfig('ui', 'formatted', ui.formatted(), 'pager') ui.setconfig('ui', 'interactive', False, 'pager') + if util.safehasattr(signal, "SIGPIPE"): + signal.signal(signal.SIGPIPE, catchterm) ui._runpager(p) return orig(ui, options, cmd, cmdfunc)