diff --git a/hgext/pager.py b/hgext/pager.py --- a/hgext/pager.py +++ b/hgext/pager.py @@ -72,6 +72,7 @@ from mercurial import ( commands, dispatch, encoding, + error, extensions, util, ) @@ -105,6 +106,9 @@ def _runpager(ui, p): 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 @@ def uisetup(ui): 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)