in reply to Tk::Progressbar gives X Error

With all of these suggestions, I came up with the following hack (ugly, but it works). Just for the sake of reference, this works for me.
use Tk; use strict; require Tk::ProgressBar; require Tk::Button; $|++; my ( $mw, $progressBar, $cancelCalButton, $runCalButton, $cancel, ); my @data = (0 .. 100); my $dataIndex; my $guiPid = $$; my $childPid; pipe(FROM_PARENT, TO_CHILD) or die "pipe: $!\n"; pipe(FROM_CHILD, TO_PARENT) or die "pipe: $!\n"; select((select(TO_CHILD), $| = 1)[0]); select((select(TO_PARENT), $| = 1)[0]); if ($childPid = fork()){ close FROM_PARENT; close TO_PARENT; } else { die "cannot fork :$!\n" unless defined $childPid; close FROM_CHILD; close TO_CHILD; while(my $line = <FROM_PARENT>){ chomp($line); print "Chid got from parent $line\n"; sleep(10); if ($line == 100){ kill('USR1',$guiPid); #tell the GUI child is done with work next; } kill('USR2',$guiPid); #tell the GUI child has update info print "sending stuff to parent\n"; print TO_PARENT "$line\n"; } print "Done with child\n"; exit(); } $mw = MainWindow->new(); $cancelCalButton = $mw->Button(-text=>"cancel", -command=>\&cancel)->p +ack(); $runCalButton = $mw->Button(-text=>"run",-command=>\&doit)->pack(); $progressBar = $mw->ProgressBar()->pack(); $mw->repeat(100,sub{$mw->idletasks}); $SIG{USR1} = sub { $cancel = 1; $progressBar->value(0); $cancelCalButton->configure(-state=>"disabled"); $mw->idletasks; }; $SIG{USR2} = sub { $runCalButton->configure(-state=>"normal"); print "Got USR2 request\n"; my $value = <FROM_CHILD>; print "parent got $value from child\n"; return if ($cancel); $progressBar->value($value); $runCalButton->configure(-state=>"disabled"); print TO_CHILD "$data[$dataIndex++]\n"; }; MainLoop; sub doit { $runCalButton->configure(-state=>"disabled"); $cancelCalButton->configure(-state=>"normal"); $mw->update; $cancel = 0; $dataIndex = 0; print TO_CHILD "$data[$dataIndex++]\n"; } sub cancel { print "@@@@@@@@@ Got Cancel button @@@@@@@@@\n"; kill('USR1',$$); }