diff mercurial/util_win32.py @ 4672:272c0a09b203

Handle CTRL+C in serve under Windows.
author Marcos Chaves <marcos.nospam@gmail.com>
date Thu, 21 Jun 2007 21:58:18 +0200
parents f97b89314fb3
children 7549cd526b7f
line wrap: on
line diff
--- a/mercurial/util_win32.py
+++ b/mercurial/util_win32.py
@@ -299,3 +299,12 @@ class posixfile_nt(object):
             raise WinIOError(err)
 
 getuser_fallback = win32api.GetUserName
+
+def set_signal_handler():
+    """Register a termination handler for console events including
+    CTRL+C. python signal handlers do not work well with socket
+    operations.
+    """
+    def handler(event):
+        win32process.ExitProcess(1)
+    win32api.SetConsoleCtrlHandler(handler)