Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/dispatch.py @ 45102:efcc87d37f4d
dispatch: handle late KeyboardInterrupt occurred in run()
User can press Ctrl+C while flushing streams in dispatch.run(). In such case,
I think exiting with 255 is better than printing Python traceback and exiting
with 1.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 13 Jul 2020 21:14:20 +0900 |
parents | 9e6b86a8f438 |
children | 9b5723784aac |
comparison
equal
deleted
inserted
replaced
45101:9e6b86a8f438 | 45102:efcc87d37f4d |
---|---|
138 # change the status code and move on. | 138 # change the status code and move on. |
139 except IOError: | 139 except IOError: |
140 status = -1 | 140 status = -1 |
141 | 141 |
142 _silencestdio() | 142 _silencestdio() |
143 finally: | 143 except KeyboardInterrupt: |
144 pass | 144 # Catch early/late KeyboardInterrupt as last ditch. Here nothing will |
145 # be printed to console to avoid another IOError/KeyboardInterrupt. | |
146 status = -1 | |
145 sys.exit(status & 255) | 147 sys.exit(status & 255) |
146 | 148 |
147 | 149 |
148 if pycompat.ispy3: | 150 if pycompat.ispy3: |
149 | 151 |