John Levon wrote:

> On Mon, Mar 22, 2004 at 09:28:01AM +0000, Angus Leeming wrote:
> 
>> John Levon wrote:
>> >> Or should the code in child_handler be truly trivial:
>> > Yes.
>> 
>> John, I take it that you're (almost) happy with the existing signal
>> handling code in error_handler below. To my mind it needs only a
>> handling_error flag to ensure that it handles multiple signals
>> safely. (The SIGPIPE should be removed if it isn't an error.)
> 
> Not really happy actually. If we get a SIGPIPE and a SIGSEGV, we'd
> lose the SIGSEGV afaics.

Hence my statement that we should remove the SIGPIPE. Ie, SIGPIPE 
signals should not be handled by error_handler. In fact we don't need 
to handle them at all.

> Also the lyxerr outputs still have a chance of not working at all,
> regardless of other signals. The issue is that the signal can come
> along asynchronously wrt state held in library code.

Understood.

> It's not a *big* deal but since you're fiddling with getting
> it right...

So outline a solution strategy. Currently we have:

    signal(SIGSEGV, error_handler);

void error_handler(int err_sig)
{
        /* print error message */

        /* Deinstall the signal handlers */

        LyX::cref().emergencyCleanup();

        lyxerr << "Bye." << endl;
        if (err_sig!= SIGHUP &&
           (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))
                lyx::support::abort();
        exit(0);
}

I take it that you would prefer:

static sig_atomic_t error_flagged_;
void error_handler(int err_sig)
{
        if (!error_flagged_)
                error_flagged_ = err_sig;
}

and that the 'real' code handling the error is then handled in the 
main program loop. However, I don't see anyway to code that up 
without using throw/catch.

-- 
Angus

Reply via email to