Re: glib & *nix signals

From: "Brian J. Tarricone" <bjt23 cornell edu>
To: gtk-app-devel-list gnome org
Subject: Re: glib & *nix signals
Message-ID: <4B6DCB57 6080408 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:

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


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...

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