octave-maintainers
[Top][All Lists]
Advanced

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

Re: interrupt handing and the GUI (bug #37672)


From: John W. Eaton
Subject: Re: interrupt handing and the GUI (bug #37672)
Date: Wed, 13 Nov 2013 03:24:23 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9

On 11/11/2013 10:47 AM, Michael Goffioul wrote:
On Mon, Nov 11, 2013 at 9:59 AM, John W. Eaton <address@hidden
<mailto:address@hidden>> wrote:

    On 11/11/2013 07:22 AM, Michael Goffioul wrote:

        I wouldn't bother too much about Windows here, as SIGINT handling is
        quite different and AFAIK *always* happen in a separate thread just
        created by the OS to handle the signal.


    So what is the fix for Windows then?  We seem to have the same
    problem there, that interrupting things like

       sleep (10);

    or

       inv (large_matrix);

    doesn't work.


Maybe using GenerateConsoleCtrlEvent [1] might do it. At least, it looks
like you'd then follow the same code path as in the CLI version.

Michael.

[1]
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683155(v=vs.85).aspx

I checked in a series of changesets that appear to fix the problem on
systems with pthreads.

  http://hg.savannah.gnu.org/hgweb/octave/rev/a38cee8f0a9b
  http://hg.savannah.gnu.org/hgweb/octave/rev/b6d07dd90f3d
  http://hg.savannah.gnu.org/hgweb/octave/rev/5c3f22dd0bbb
  http://hg.savannah.gnu.org/hgweb/octave/rev/2a4acd6548c6
  http://hg.savannah.gnu.org/hgweb/octave/rev/b5bf26a054bd

It works on my Debian system.  I ended up using both pthread_sigmask
to block SIGINT in all threads and then unblock it in the thread that
is running the Octave interpreter.  Then I also used pthread_kill to
direct the SIGINT signal to the thread that is running the
interpreter.  That seemed to work.  Using only pthread_kill was not
enough because it's possible for SIGINT to be generated in other ways
and bad things can happen if it is delivered to any thread other than
the one running the interpreter.

The signals are now sent from some functions in a new class in
libgui/src/thread-manager.cc.

The implementation for Unix uses the pthread_sigmask and pthread_kill
functions.

The implementation for Windows is still calling "::raise (SIGINT)".  I
tried using "GenerateConsoleCtrlEvent (CTRL_C_EVENT, 0)" but that
still crashes Octave if it is expecting to be able to longjmp out of
the signal handler back to the most recent "safe" location.  I don't
know how to fix this problem yet.  If anyone has a clue, help would be
most appreciated.

jwe




reply via email to

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