Re: [gtkmm] Spawing a process and being notified of its termination
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtkmm-list gnome org
- Cc: Enrico Zini <zinie cs unibo it>, Paul Davis <paul linuxaudiosystems com>
- Subject: Re: [gtkmm] Spawing a process and being notified of its termination
- Date: Thu, 26 Aug 2004 21:28:43 +0100
On Sunday 22 August 2004 22:56, Enrico Zini wrote:
> On Sun, Aug 22, 2004 at 11:24:51PM +0200, Enrico Zini wrote:
> > Almost there. I wrote code to create a pipe and set it in nonblocking
> > mode, to avoid the signal handler to block if the Gtk main loop has
> > something else to do and isn't reading from the pipe.
> > Now I'd like to add reading the pipe in the Gtk event loop, but:
>
> I reply myself, as I solved the problem: while desperately looking at
> the Gtkmm namespace in search for some clue, I stumbled on the
> Glib::Dispatcher class, which does exactly what I want: you call its
> emit() method anywhere and it activates a slot in the correct place in
> the Glib event loop. Or at least this is what I understood.
As I understand it Glib::Dispatcher is really intended for communicating
between threads. The functions which IEEE Std 1003.1 requires to be
async-signal-safe (which may be called in an asynchronous signal handler) are
much smaller in number than those required to be thread safe, so you may
encounter problems. Compare
http://www.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_04.html
with
http://www.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_09.html.
Although Glib::Dispatcher uses a pipe to implement the signalling (so it may
be kosher), it would be a good idea to check the code and see what it gets up
to, or (better in my view) implement a blocking pipe yourself, which is very
easy to do. You would normally plumb the pipe into the main program loop
using Glib::signal_io().connect();
An alternative is for the signal handler just to set a flag (of type volatile
sigatomic_t) and then to check for it in a timer slot (you would normally
connect to the slot using using Glib::signal_timeout().connect()).
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]