Re: glib & *nix signals
- From: "Brian J. Tarricone" <bjt23 cornell edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: glib & *nix signals
- Date: Sat, 06 Feb 2010 12:04:39 -0800
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]