Re: glib & *nix signals

On 02/04/2010 11:11 AM, Thomas Stover wrote:
I'm looking for some notes / advise on catching SIGTERM in a glib main
loop based program. 
Mainly on linux, but other kernels would be nice. This article:

for instance, recommends masking all signals all the time and creating a
dedicated thread siting around in a call to sigwait(). Translating that
into glib threads might work. Any thoughts?

I usually create a pipe (see pipe(2)), wrap the read side in a
GIOChannel, and watch it via g_io_add_watch().  Then I write to that
pipe in my signal handler.  When the main loop wakes up again, it'll run
the IO watch's callback function.  See:

for some example code.  It's simple and doesn't require the use of threads.


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