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: > > http://www.linuxjournal.com/article/2121 > > 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: http://git.xfce.org/xfce/libxfce4util/tree/libxfce4util/xfce-posix-signal-handler.c for some example code. It's simple and doesn't require the use of threads. -brian _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list