Re: Handling Unix signals?



On Thursday 03 March 2005 13:29, Toralf Lund wrote:
> Igor Gorbounov wrote:
[snip]

>> I've got an advice here to use any way to send a message to MainLoop 
>> (see the mailing list
>> for 21.02.2005). I've choosen the Glib::Dispatcher for this purpose, 
>
> Ah. Yes. That seems to be more or less exactly what I was looking for,
> only I couldn't find the right spot in the documentation. Thanks.
>
> > some gurus say that
> > it may cause problems sometimes...
>
> What exactly would those problems be? I found some comments in earlier
> list posts, but they left me none the wiser...

[snip]

The problem is that you can only use async-signal-safe functions in a signal 
handler.  Glib::Dispatcher is designed to be thread safe, not 
async-signal-safe, and you would need to examine the code for 
Glib::Dispatcher to see if calling emit() on a Dispatcher object also meets 
the async-signal-safe requirement (it quite possibly does).  See paragraph 
2.4.2 of the Single Unix Specification, System Interfaces, Signal Concepts, 
General Information, at http://www.unix.org/single_unix_specification/ for 
the list of async-signal-safe functions.

You can easily do it yourself - create a pipe, plumb it into the main program 
loop with Glib::signal_io().connect() and then have the signal handler put a 
byte in the pipe (write() is async-signal-safe).

Chris.



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