Mercurial > hg
changeset 30897:253d5c0f3a2f
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.
author | Simon Farnsworth <simonfar@fb.com> |
---|---|
date | Wed, 08 Feb 2017 07:44:10 -0800 |
parents | b9116befa784 |
children | 4d019d0e1b3b |
files | hgext/pager.py |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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)