# HG changeset patch # User Patrick Mezard # Date 1182457181 -7200 # Node ID d8442fc0da8dd45becf49a1915f014c4e6df2881 # Parent 150afe6becf62f04e28f1ccbf92f971ccb3f2924# Parent 272c0a09b2032046de3671eada475e1eace2b772 Merge with crew diff -r 150afe6becf6 -r d8442fc0da8d mercurial/commands.py --- a/mercurial/commands.py Thu Jun 21 13:09:01 2007 -0500 +++ b/mercurial/commands.py Thu Jun 21 22:19:41 2007 +0200 @@ -2432,6 +2432,7 @@ class service: def init(self): + util.set_signal_handler() try: self.httpd = hgweb.server.create_server(parentui, repo) except socket.error, inst: diff -r 150afe6becf6 -r d8442fc0da8d mercurial/util.py --- a/mercurial/util.py Thu Jun 21 13:09:01 2007 -0500 +++ b/mercurial/util.py Thu Jun 21 22:19:41 2007 +0200 @@ -1100,6 +1100,9 @@ return p_name return default + def set_signal_handler(): + pass + def find_exe(name, default=None): '''find path of an executable. if name contains a path component, return it as is. otherwise, diff -r 150afe6becf6 -r d8442fc0da8d mercurial/util_win32.py --- a/mercurial/util_win32.py Thu Jun 21 13:09:01 2007 -0500 +++ b/mercurial/util_win32.py Thu Jun 21 22:19:41 2007 +0200 @@ -299,3 +299,12 @@ 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)