[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Ctrl-C & error handling
From: |
John W. Eaton |
Subject: |
Re: Ctrl-C & error handling |
Date: |
Sun, 29 Mar 2009 15:49:11 -0400 |
On 29-Mar-2009, Jaroslav Hajek wrote:
| On Sun, Mar 29, 2009 at 4:09 PM, Jaroslav Hajek <address@hidden> wrote:
| > On Sun, Mar 29, 2009 at 3:39 PM, John W. Eaton <address@hidden> wrote:
| >> On 29-Mar-2009, Jaroslav Hajek wrote:
| >>
| >> | is there any possibility for an m-function to implement a custom
| >> | cleanup when Ctrl-C is detected? unwind_protect does not seem to catch
| >> | Ctrl-C.
| >> | The problem is that if a function manipulates system resources in a
| >> | non-trivial manner, like parcellfun from the general package, it is
| >> | not easy to manually clean up (parcellfun interrupted by Ctrl-C leaves
| >> | hanging processes in the memory).
| >>
| >> The unwind-protect mechanism is intended to handle interrupts, so I
| >> think it is a bug if somehow Ctrl-C jumps back to the top level
| >> without evaluating the cleanup blocks.
| >>
| >
| > OK, I hoped so. So the following simplistic script does not work:
| >
| > unwind_protect
| > pause(10);
| > unwind_protect_cleanup
| > disp ("break");
| > end_unwind_protect
| >
| > when I run it and press Ctrl-C, nothing is displayed.
| >
| >
|
| I pushed the following change:
| http://hg.savannah.gnu.org/hgweb/octave/rev/eabdfcc977f1
|
| I'm not sure it is the right thing, but it seems to do what I want.
I'll have to think about it, but it seems likely that your change is
correct. Thanks for looking at it.
| Should try/catch catch interrupts, too?
I don't think of interrupts as errors/exceptions, so I don't think it
should. Also, I don't think Matlab's try/catch does, so we might
generate compatibility complaints if we changed Octave's try/catch
behavior wrt interrupts.
jwe