> From: "Brian J. Tarricone" <bj...@cornell.edu>
> To: gtk-app-devel-list@gnome.org
> Subject: Re: glib & *nix signals
> Message-ID: <4b6dcb57.6080...@cornell.edu>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> 
> 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
> 

That's conceptually what I have done in the past (my life before glib).

>From what I can tell there are three ways.

1) GIOChannel and signalfd(2) on linux > 2.6.27

2) the pipe(2) technique (probably only justifiable if no threads are in
the picture)

3) dedicated signal listening thread which when signaled, grabs a lock on
a worker thread's g_main_context, sets up an idle event, and let's worker
thread's idle callback deal with it

In the end, I'll probably make some abstraction that does one #1 if
signalfd() is available, #3 if g_threads are engaged, and #2 otherwise.

I'll have to go look at what to do in cygwin to...

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to