changeset 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 a5fa2761a6cd
files mercurial/dispatch.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Mon Jul 13 21:06:34 2020 +0900
+++ b/mercurial/dispatch.py	Mon Jul 13 21:14:20 2020 +0900
@@ -140,8 +140,10 @@
                 status = -1
 
         _silencestdio()
-    finally:
-        pass
+    except KeyboardInterrupt:
+        # Catch early/late KeyboardInterrupt as last ditch. Here nothing will
+        # be printed to console to avoid another IOError/KeyboardInterrupt.
+        status = -1
     sys.exit(status & 255)