[Top][All Lists]

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

Signal handling?

From: John W. Eaton
Subject: Signal handling?
Date: Thu, 8 Nov 2001 22:59:32 -0600

On 31-Oct-2001, Peter Brinkmann <address@hidden> wrote:

| How can I change the way octave handles signals (keyboard interrupt in
| particular)? 
| Consider, for example, the following code:
|       try
|               try
|                       while 1
|                       end
|               catch
|                       disp('Catch 1')
|               end
|               disp('foo')
|       catch
|               disp('Catch 2')
|       end
| After hitting Ctrl-C in order to break the infinite loop, I'd like to
| continue with the line that displays 'foo' (that's the way matlab handles
| the keyboard interrupt), but octave skips to the next catch block instead.
| How can I fix this?

You'd have to modify the sources.

Since an interrupt (Ctrl-C) is supposed to eventually send you back to
the prompt, I'm not sure that the Matlab behavior is really best.
What happens for something like

  while 1
      do_something (that, takes, a, long, time);
    do_something_else (that, takes, almost, no, time, at, all);

?  Can you ever get out of the loop by typing Ctrl-C (assuming you are
not lucky enough to generate the interrupt when Matlab is processing
the task outside of the try-catch block)?

Anyway, to get Octave to behave like Matlab in this case would require
substantial changes to the way Octave handles interrupts.  Not that
that would be a bad thing though, since there are some problems with
the way things currently work...

BTW, Octave only appears to be skipping to the next catch block.  What
it is really doing is running all the cleanup code on the way to the
top level.  I'm not sure that's the right thing to do for interrupts.
Are they errors?


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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