bug-hurd
[Top][All Lists]
Advanced

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

Re: console-client signal handling


From: Roland McGrath
Subject: Re: console-client signal handling
Date: Tue, 20 Jul 2004 20:31:50 -0400 (EDT)

> I have doubts if calling console_exit, and thus driver_fini, is safe
> at all from a signal handler.

This really depends on what kinds of things other code in console-client
might be doing when it's interrupted.  If you're not 100% sure, just
setting a flag is the safe thing.

> Usually, with threads, you get extra problems with signal handling.
> But for a simple handler that just causes a flag to be set or an
> exit() to be triggered I don't think it matters.  

Actually, calling exit in a signal handler is not kosher (but _exit is).

> The reason I am careful here is that you don't know what's going on
> inside a driver, and if you terminate it, it might want to communicate
> with some worker threads for cleanup, and that won't work if it's that
> worker thread which is currently running in the signal handler trying
> to call driver_fini, for example.  Also, there are a whole slew of
> functions that are not safe to call from within a signal handler, for
> example malloc().  Another function I'd be careful about is dlclose,
> which is used in driver_fini().

Calling dlclose inside a handler is definitely not safe.  POSIX defines a
specific list of safe functions, and in the Hurd beyond that all RPC stubs
should be safe and not much else.




reply via email to

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