Re: Unix signals in GLib

On 2010-04-30 13:38, Matthew Bucknall wrote:
> Find attached an excerpt from an application of mine. Not entirely
> self-contained, but you should get a general idea of what is going on.
> Using the attached code, my application calls app_signal_block_unused()
> early on during initialization. The signal listening thread is
> initialized and started by app_signal_init(). The thread is stopped (in
> case it has not already stopped) by calling app_signal_cleanup() as the
> application finalizes.
> You'll notice in read_handler() I call a function called
> app_context_stop(). Replace this function with whatever you need to stop
> your application's main loop.

If you're using a normal glib GMainLoop, one can do this in a simpler
manner without the pipe, since calling g_main_loop_quit() directly from
the sigwait thread is safe.



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