AW: Ending up with Zombie process



Hello Again
 
I just read my own mail and saw that it is not clear that both processes should run on the same machine.
I don't have to care about processes on other computers. This is part of the installer and  irrelevant for me.
 
 
Regard
Josef
 


Von: gtk-perl-list-bounces gnome org [mailto:gtk-perl-list-bounces gnome org] Im Auftrag von Eisenknapp, Josef
Gesendet: Montag, 30. Jänner 2006 11:08
An: gtk-perl-list gnome org
Betreff: Ending up with Zombie process

Hello again
 
The more complex my program is, the more questions i have :-)
 
My Gui should collect a bunch of values an then start a process which installs something on another computer.
To get status information to the gui during the installation process i thought about using a pipe for comunication between the gui and the installer.
 
 
 
Like described in the study guide example I open a pipe an run an example process (write_to_fff.pl).
    ------------------------------------------------------------------------
   my $fh = new IO::Pipe;
   $fh->reader("./write_to_fff.pl");
 
    my $helper_tag = Gtk2::Helper->add_watch(fileno $fh, 'in',sub{
        &watch_callback($fh)
        });
    ------------------------------------------------------------------------
 
    ----------------------------------------------------------
    # this is my write_to_fff.pl
    ------------------------------------
    #! /usr/bin/perl -w
 
    use strict;
    use warnings;
 
    my $i = 1;
 
    while($i < 10){
 
    print "Loop $i\n";
    system ("");
    $i ++;
     sleep 2;
    }
    -------------------------------------------------------------------
 
in the watch_callback() i currently just print the child process' output to STDOUT
 
    ------------------------------------------------------------------------
    sub watch_callback{

    print "callback called\n";
    my ($fh) = @_;
 
    my $line;
    $fh->sysread($line,1000);
    chomp $line;
    if($line){
          print $line. "\n";
    }
    else{
          print "remove helper\n";
          Gtk2::Helper->remove_watch($helper_tag);
    }
 
    return TRUE;
    }
    ------------------------------------------------------------------------
 
 
 
This works pretty fine, but when the process "write_to_fff.pl" terminates it becomes a ZOMBI.
 
Can anyone tell me how to avoid this?
 
I tried it like in "Programming Perl" with:
 
my $kid;
do {
    $kid = waitpid(-1, &WNOHANG);
}until $kid == -1;
 
Then the Process terminated corretly, but my watch_callback() isn't called until "write_to_fff.pl" terminates.
 
 
 
 
 
Thanks in advance
Josef
 


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