Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/dispatch.py @ 32044:cde72a195f32
dispatch: ignore further SIGPIPE while handling KeyboardInterrupt
I got the following error by running "hg log" and quitting the pager
immediately. Any output here may trigger another SIGPIPE, so only thing
we can do is to swallow the exception and exit with an error status.
Traceback (most recent call last):
File "./hg", line 45, in <module>
mercurial.dispatch.run()
File "mercurial/dispatch.py", line 83, in run
status = (dispatch(req) or 0) & 255
File "mercurial/dispatch.py", line 167, in dispatch
req.ui.warn(_("interrupted!\n"))
File "mercurial/ui.py", line 1224, in warn
self.write_err(*msg, **opts)
File "mercurial/ui.py", line 790, in write_err
self._write_err(*msgs, **opts)
File "mercurial/ui.py", line 798, in _write_err
self.ferr.write(a)
File "mercurial/ui.py", line 129, in _catchterm
raise error.SignalInterrupt
mercurial.error.SignalInterrupt
Perhaps this wasn't visible before de5c9d0e02ea because the original stderr
handle was restored very late.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 17 Apr 2017 23:53:19 +0900 |
parents | 38963a53ab0d |
children | 616e788321cc |
comparison
equal
deleted
inserted
replaced
32043:b844d0d367e2 | 32044:cde72a195f32 |
---|---|
163 try: | 163 try: |
164 ret = _runcatch(req) | 164 ret = _runcatch(req) |
165 except KeyboardInterrupt: | 165 except KeyboardInterrupt: |
166 try: | 166 try: |
167 req.ui.warn(_("interrupted!\n")) | 167 req.ui.warn(_("interrupted!\n")) |
168 except error.SignalInterrupt: | |
169 # maybe pager would quit without consuming all the output, and | |
170 # SIGPIPE was raised. we cannot print anything in this case. | |
171 pass | |
168 except IOError as inst: | 172 except IOError as inst: |
169 if inst.errno != errno.EPIPE: | 173 if inst.errno != errno.EPIPE: |
170 raise | 174 raise |
171 ret = -1 | 175 ret = -1 |
172 finally: | 176 finally: |