Re: forking a new mainwindow from a module
- From: muppet <scott asofyet org>
- To: zentara <zentara zentara net>
- Cc: gtk-perl-list gnome org
- Subject: Re: forking a new mainwindow from a module
- Date: Fri, 6 May 2005 19:10:29 -0400
On May 6, 2005, at 5:42 PM, zentara wrote:
Any ideas on what I can do to fix this?
What's happening is that the child is inheriting the X connection
socket from the parent, and both the child and parent are trying to
communicate over the same socket. It blows up just like two threads
trying to talk at the same time.
I presume that the Tk version didn't do that because it initializes X
differently. It works with other programs because they're not fighting
for the same X connection.
Here's a minor hack of your module to exec itself in the child to force
the socket to close.
package GMeM;
use warnings;
use strict;
my $pid =$$;
print "$pid\n";
if ($ARGV[0] eq 'GMeM-Show-Things') {
use Gtk2 '-init';
$pid = $ARGV[1];
my $win = Gtk2::Window->new('toplevel');
$win->signal_connect( 'destroy' => \&delete_event );
my ($xscr, $yscr) = (Gtk2::Gdk->screen_width,
Gtk2::Gdk->screen_height);
$win->move($xscr - 80, $yscr - 15);
my $lab = Gtk2::Label->new("PID: $pid-> " );
my $font = Gtk2::Pango::FontDescription->from_string("Sans Bold
14");
$lab->modify_font($font);
$win->add($lab);
$win->show_all();
Gtk2->main;
#####################################
sub delete_event { Gtk2->main_quit; return 0; }
exit;
} elsif (fork() == 0) {
print "forked ok\n";
exec "$^X -MGMeM -e1 GMeM-Show-Things $pid";
}
1;
--
That's it! It's one thing for a ghost to scare my children, but it's
another to play my theremin!
- Homer Simpson
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]