octave-maintainers
[Top][All Lists]
Advanced

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

Re: Patch to Octave shutdown procedures


From: Jaroslav Hajek
Subject: Re: Patch to Octave shutdown procedures
Date: Wed, 20 May 2009 07:31:52 +0200

On Wed, May 20, 2009 at 5:58 AM, John Swensen <address@hidden> wrote:
>
> On May 19, 2009, at 3:56 PM, Jaroslav Hajek wrote:
>
>> On Tue, May 19, 2009 at 9:36 PM, John Swensen <address@hidden>
>> wrote:
>>>
>>> On May 19, 2009, at 3:21 PM, Jaroslav Hajek wrote:
>>>>
>>>> But why don't you call octave_main with embedded = true and just call
>>>> main_loop afterwards?
>>>>
>>>> octave_main (argc, argv, true);
>>>>
>>>> // possibly call install_signal_handlers () and adjust the handlers
>>>>
>>>> main_loop ();
>>>>
>>>> // cleanup
>>>> do_octave_atexit ();
>>>> sysdep_cleanup ();
>>>>
>>>> what's the problem with this scheme?
>>>>
>>>>
>>>
>>> I think there are 2 problem with this approach:
>>> 1) That still doesn't solve the problem of the Octave quit function and
>>> the
>>> signal handlers calling exit().  I suppose I could replace all the Octave
>>> signal handlers with my own, but that seems like just asking for trouble
>>> and
>>> would still have the problem with the Octave quit function.
>>
>> I think your approach solves the problem with signal handlers neither.
>> quit() is a real trouble.
>> Maybe it'd be best if there was an octave_exit function pointer, that
>> could be replaced?
>> In all places where we call exit() now, we'd just just call
>> (*octave_exit)().
>>
>
> The patch I submitted does solve the problem with the Octave quit function
> by bypassing the call to exit().  However, I do like the idea of creating an
> octave_exit() function that could be replaced.  I will work on a patch along
> these lines.
>

I can do it. This issue affects other projects I'm interested in, too.
There should really be a clean way to prevent quit() from terminating
the whole process if Octave is embedded. It never occured to me before
:)

>>> 2) How do you force octave_parse () to return something other than zero
>>> to
>>> make it exit the main_loop function?  I tried looking through parse.cc,
>>> but
>>> can't understand exactly what is going on in the octave_parse function
>>> (#defined as the yyparse function) and what exact condition will cause it
>>> to
>>> return a non-zero value.
>>>
>>
>> how do you supply input to Octave? just writing EOF to the stream
>> where Octave reads its input from should suffice.
>> manually setting parser_end_of_input may also work, but I wouldn't
>> recommend it.
>>
> I verified this works for OSX and Linux, but in Windows if I send an EOF
> (0x04)  to the terminal does it do the same thing?
>

I'm not sure; however, maybe rather than explicitly writing 0x04 you
can just normally close the stream on the writing side - using fclose,
close (with file descriptors) or whatever types of streams you use.
That should, IMHO, work equally well on all platforms. Or is OctaveDE
using some more complicated mechanism? I'll try looking at its code.

cheers

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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