Re: trouble with reading from pipes



On Wed, 25 Jan 2006 12:42:31 -0600
Daniel Davidson <danield igb uiuc edu> wrote:

This may be a problem with my understanding of perl and not with GTK,
but here goes anyway.

In my program I create three pairs of pipes:

pipe($fractread,$fractwrite);
pipe($progread,$progwrite);
pipe($statusread,$statuswrite);

which I plan to use to get information from forked functions.

I also set up a watcher to notice when one of these pipes are written to
by the child process.

$tag = Gtk2::Helper->add_watch(fileno($fractread), 'in', \&setstatus);
sub setstatus{
     $progressbar->set_text(<$progread>);
     $progressbar->set_fraction(<$fractread>);
     Gtk2->main_iteration while Gtk2->events_pending;
     print "in status\n";
        return 1;  #so callback continues

}

And finally in the child process I print to the pipe.
     print $fractwrite $count/$totaldays;
     print $statuswrite "Populating Database $count of $totaldays
".int($count/$totaldays*100)."%";

Only problem is that nothing ever happens, even though I know the child
process is running.  Any ideas what I am screwing up?

It just so happens today I was studying the Chapter cover Gtk2::Helper.

Get this great tutorial at:
http://forge.novell.com/modules/xfcontent/downloads.php/exam/documentation/



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



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