Re: forking an external process



On tir, 2002-05-07 at 22:04, Kim Schulz wrote:

I want my gui to be accesable even when an external process is doing
some work.
My program does the following:
initialise the GUI
exec of a wget process
wait for it to return 
do somthing to the return which will update the GUI (add rows to a
clist)


Rather than figuring out how fork and friends work you might want to do
something like the following (not tested):

    my $xml = "";
    my $ua= LWP::UserAgent->new;
    my $request = HTTP::Request->new('GET',
    'http://www.slashdot.org/slashdot.rdf');
    my $response = $ua->request($request, sub {
            my($data, $response, $protocol) = @_;
    
        # do something to data
            $xml .= $data;
    
            Gtk->main_iteration while Gtk->events_pending;
    }, 4096);
    
    here $xml should hold the file...


./borup




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