From d1d47a3ff28641eb3bdf049c9e61177a9127ad67 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 10 Nov 2011 14:41:23 +0100 Subject: [PATCH] [FIX] Hitting ^C on Windows is broken, this patch should address the situation. This patch is adapted for trunk from the one provided by Olivier Ligot from Group S for 6.0. bzr revid: vmt@openerp.com-20111110134123-9sxi1s86pp242wbe --- openerp-server | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/openerp-server b/openerp-server index f17627906f1..71a52d5f06b 100755 --- a/openerp-server +++ b/openerp-server @@ -179,9 +179,12 @@ def dumpstacks(sig, frame): def setup_signal_handlers(): """ Register the signal handler defined above. """ SIGNALS = map(lambda x: getattr(signal, "SIG%s" % x), "INT TERM".split()) - map(lambda sig: signal.signal(sig, signal_handler), SIGNALS) if os.name == 'posix': + map(lambda sig: signal.signal(sig, signal_handler), SIGNALS) signal.signal(signal.SIGQUIT, dumpstacks) + elif os.name == 'nt': + import win32api + win32api.SetConsoleCtrlHandler(lambda sig: signal_handler(sig, None), 1) def quit_on_signals(): """ Wait for one or two signals then shutdown the server. @@ -191,9 +194,12 @@ def quit_on_signals(): """ # Wait for a first signal to be handled. (time.sleep will be interrupted - # by the signal handler.) - while quit_signals_received == 0: - time.sleep(60) + # by the signal handler.) The try/except is for the win32 case. + try: + while quit_signals_received == 0: + time.sleep(60) + except KeyboardInterrupt, e: + pass if config['pidfile']: os.unlink(config['pidfile'])