Marcus Brinkmann <[EMAIL PROTECTED]> writes: > At Wed, 14 Jul 2004 22:44:33 +0200, > marco_g wrote: >> >> This patch fixes the problem. Marcus, can I commit this patch? > > A minor nit: Define the macro inside the main function, just before > using it, and maybe undef it afterwards.
Ok. > However, I have a big concern: > > I have doubts if calling console_exit, and thus driver_fini, is safe > at all from a signal handler. You might have to set some global flag, > possibly protected by a spin lock (not mutex, I guess), which is then > checked periodically by some other thread. Can't I use conditions instead? > 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. Still, might be > worth to block signals for all threads except the main thread. Maybe. > I have not thought about it much at all. Also depends on the handler > code of course. Ok. > 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(). I understand. > So, this might need more work. There was a reason I didn't add it > earlier :) So what I will do is creating an additional thread that waits for a condition and calls console_exit when the condition is signalled. The sighandler will just signal the condition. Thanks, Marco _______________________________________________ Bug-hurd mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-hurd