octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does signal trap of CTRL-CLOSE event allowable to be used on windows


From: Michael Goffioul
Subject: Re: Does signal trap of CTRL-CLOSE event allowable to be used on windows?
Date: Wed, 13 Jul 2011 11:10:20 +0100

That's worth a try. But from the experience of handling CTRL-C event
(which usually crashes
octave), it may not be as easy as it sounds.

Michael.


On Tue, Jul 12, 2011 at 7:36 PM, Tatsuro MATSUOKA <address@hidden> wrote:
> Hello
>
> Pressing 'X' button on the right upper side windows console always induce 
> error.
> If we use  SetConsoleCtrlHandler function and trap CTRL-CLOSE event, we may 
> eliminate annoy the error.
>
> In src/sighandlers.cc,  I found
>
> #**From here
> #ifdef USE_W32_SIGINT
> static BOOL CALLBACK
> w32_sigint_handler (DWORD sig)
> {
>   const char *sig_name;
>
>   switch(sig)
>     {
>       case CTRL_BREAK_EVENT:
>         sig_name = "Ctrl-Break";
>         break;
>       case CTRL_C_EVENT:
>         sig_name = "Ctrl-C";
>         break;
>       case CTRL_CLOSE_EVENT:
>         sig_name = "close console";
>         break;
>       case CTRL_LOGOFF_EVENT:
>         sig_name = "logoff";
>         break;
>       case CTRL_SHUTDOWN_EVENT:
>         sig_name = "shutdown";
>         break;
>       default:
>         sig_name = "unknown console event";
>         break;
>     }
>
>   switch(sig)
>     {
>       case CTRL_BREAK_EVENT:
>       case CTRL_C_EVENT:
>         w32_raise (SIGINT);
>         break;
>
>       case CTRL_CLOSE_EVENT:
>       case CTRL_LOGOFF_EVENT:
>       case CTRL_SHUTDOWN_EVENT:
>       default:
>         // We should do the following:
>         //    clean_up_and_exit (0);
>         // We can't because we aren't running in the normal Octave thread.
>         user_abort(sig_name, sig);
>         break;
>     }
>
>   // Return TRUE if the event was handled, or FALSE if another handler
>   // should be called.
>   // FIXME check that windows terminates the thread.
>   return TRUE;
> }
> # ***********here END
>
> If we manipulate arround
>   case CTRL_CLOSE_EVENT:
>
> we may avoid the annoying the error.
>
> Regards
>
> Tatsuro
>
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]