Re: Handling Unix signals in a GTK+ application



On Saturday 11 March 2006 22:36, Thomas Okken wrote:
[Using a pipe] is generally the best way of dealing
with asynchronous (Unix) signals, but for simple
cases another approach is just to set a flag of type
volatile sig_atomic_t in the Unix signal handler,
and then check and act on the status of the flag in
the glib event loop with an idle handler set up with
g_idle_add().

The downside of that approach is that you have to
busy-wait on that flag, while the pipe approach allows
the application to be completely idle (and still have
fast response to the signal)... I went with the pipe
approach; using the sample code referred to by another
poster, it turned out to be pretty easy.

That's not right.  Idle handlers do not busy wait.  They do trigger 
invocations of the event loop at indeterminate intervals.  They are also very 
common (if you don't want to communicate with the glib event loop from other 
threads with a pipe, you are likely to end up with using a GAsyncQueue object 
and an idle handler).

Chris






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