On Tue, 1 Sep 2015 13:54:34 +0200
rastersoft <ras...@rastersoft.com> wrote:
> Hi all:
> 
> I'm working on a project which, for several reasons, will use the
> Posix fork() call. The question is: if I have an active GTK main loop
> in the program before calling fork(), is there something I have to do
> after calling it in the child process? I know that I must NOT use Gtk
> calls in the child, but should I quit the main loop in the child?
> Should I quit before the Gtk main loop, create the child, and call it
> again? What can I do to don't loose registered callbacks and so on?

Because of gio, which uses background threads for some of its stuff
(in particular for its async i/o operations) all GTK+ programs are in
effect multi-threaded nowadays.  This makes calling fork() problematic,
because as you probably know POSIX only permits async-signal-safe
functions to be called after a fork() and before an exec() in a
multi-threaded program.  If you want to do anything other than a fork()
and an exec(), then start a thread not a new process.  This leaves your
question redundant.

For asynchronous tasks you might want to look at GTask (available from
glib-2.36).  For an encapsulation of the fork()/exec() approach, see
also GSubProcess, available from glib-2.40.

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

Reply via email to