On Thu, 13 Jun 2002 gtk-perl-list@xxxxxxxxxxxxxxxxxx wrote:
> The problem is not the fork, per se. The problem is the exit(3).
> It is a common problem with forking: Both processes think they
> should clean up when they exit. In your case, gtk (or maybe it is
> xlib or gdk?) calls shutdown(2) on the connection to X when the
> child exits, so the connection is broken when the parent tries to
> use it. You can see this clearly with strace (on Linux).
>
> In general, you should make sure that objects are only destroyed by
> one of the forks.
>
> One solution, as you know, is to make sure gtk is initialized only
> in one process, by forking before initializing. Another is to
> prevent clean-up routines from running in the child by calling
> _exit(2), aka POSIX::_exit.
>
> gtk probably should have a way to tell it not to clean up in the
> current process. That would be the ideal solution, because other
> clean-ups (eg, for objects initialized in the child) could still
> run.
Thanks for the quick response. I added a call to POSIX::_exit(0) in the
child and the Broken Pipe error went away.
--
~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~=-., \|/ (___) \|/ _,.-=~'`^`
Brian Medley @~./'O o`\.~@
"Knowledge is Power" brian.medley@xxxxxxxxxxx /__( \___/ )__\ *PPPFFBT!*
-- Francis Bacon `\__`U_/'
_,.-=~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~= <____|' ^^`'~=-.,__,.-=
~`'^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-==--^'~=-.,__,.-=~'`^`
|