bug-hurd
[Top][All Lists]
Advanced

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

Re: console-client signal handling


From: Marco Gerards
Subject: Re: console-client signal handling
Date: Wed, 21 Jul 2004 13:15:07 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Marcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de> 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





reply via email to

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