# HG changeset patch # User Michael Goffioul # Date 1385057643 18000 # Node ID 54784619350bf7c3dcdcacdbf095667c25666f8c # Parent f6e1be4ad92364b50b98b67bd39da53234b4ac9d Make CTRL-C to work in GUI with "system" calls. * libgui/src/thread-manager.cc (block_or_unblock_signal): Don't do anything on Win32 platform, as thread-specific signal handling is not supported. This allow to delay SetConsoleCtrlHandler after AllocConsole. (windows_thread_manager::interrupt): Call GenerateConsoleCtrlEvent instead of w32_raise_sigint. diff -r f6e1be4ad923 -r 54784619350b libgui/src/thread-manager.cc --- a/libgui/src/thread-manager.cc Tue Nov 19 15:47:06 2013 -0500 +++ b/libgui/src/thread-manager.cc Thu Nov 21 13:14:03 2013 -0500 @@ -48,7 +48,7 @@ void interrupt (void) { - w32_raise_sigint (); + GenerateConsoleCtrlEvent (CTRL_C_EVENT, 0); } }; @@ -90,15 +90,20 @@ static void block_or_unblock_signal (int how, int sig) { +#if ! defined (__WIN32__) || defined (__CYGWIN__) + // Blocking/unblocking signals at thread level is only supported + // on platform with fully compliant POSIX threads. This is not + // supported on Win32. Moreover, we have to make sure that SIGINT + // handler is not installed before calling AllocConsole: installing + // a SIGINT handler internally calls SetConsoleCtrlHandler, which + // must be called after AllocConsole to be effective. + sigset_t signal_mask; sigemptyset (&signal_mask); sigaddset (&signal_mask, sig); -#if defined (__WIN32__) && ! defined (__CYGWIN__) - sigprocmask (how, &signal_mask, 0); -#else pthread_sigmask (how, &signal_mask, 0); #endif }