Re: [gtkmm] Spawing a process and being notified of its termination

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.

Anyway, for the records, I now have this very nice thing:

static Glib::Dispatcher dispatcher;

static void termination_handler(int signum)

// later on...

	// Connect the dispatcher to the child exit signal

	// Setup the SIGCHLD handler
	struct sigaction new_action;
	new_action.sa_handler = termination_handler;
	new_action.sa_flags = SA_NOCLDSTOP; //0;
	sigaction(SIGCHLD, &new_action, NULL);

So far, it works nicely!



GPG key: 1024D/797EBFAB 2000-12-05 Enrico Zini <enrico debian org>

Attachment: signature.asc
Description: Digital signature

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