Re: [gtk-list] Re: fork & gtk-perk = nono



On Mon, 7 Sep 1998, Paolo Molaro wrote:

> On Sun, Sep 06, 1998 at 05:27:09PM -0400, Kenneth Albanowski wrote:
> > I'm forwarding this to the list for Marc Lehmann. He's noted that forking
> > from within Gtk/Perl does not work very well. I'm not enough of an expert
> > in X to know for sure whether this is a fundamental X glitch, a Gtk
> > limitation, or just a bug.
> 
> There is the same problem in C as it is X related (open file handles sharing).

Well, open files allows the problem, but it doesn't cause the problem. It
would appear that atexit() sharing is causing the problem, as the exiting
task sends some sort of command to X to shut down the link, beyond simply
closing the socket.

> If you fork you need to either exec*() or _exit() (note the underline).
> We could add a Gtk->_exit() function that calls _exit() but
> using something like _exit() in perl is not a good idea, I think.
> A way to solve the problem without changes to perl and the Gtk module
> is to use something like this as you pointed out:
> 
> use Gtk;
> 
> fork || do { 
> 	do_stuff; 
> 	exec('true')
> };
> 
> sleep 1;
> Gtk->exit(0);

Or as Owen said, use _exit from the POSIX libs.

Thanks for the explanation, though I'll see if I can't come up with some
more elegant approach to using fork.

-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)




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