I am trying to write a program in ActivePerl for win32, needing to fork my code into three processes.
I am trying the code below, but I only get one child (2 processes counting the parent).
**********
defined ($pid1=fork())||die "fork failed $!";
if ($pid1>0) {#Parent Here.
            defined($pid2=fork())||die "fork failed $!";

  }

#Code to be executed by both parent and children here.
**********
Then, I wish for the child processes to end, leaving only the parent. Since in my program I cannot create
a second child (3 processes in all), I use the following code to terminate the child.

**********
#Code to be executed by both parent and children here.

unless($pid1){  #Parent here.
    exit;     
              }                 
if($pid1>0){  #Parent here.
    waitpid($pid1,0);
    }
#Code that only the Parent (Child is "dead") executes from now on.
**********

How can I get 3 fully working processes? (1 Parent 2 Children) ?? And even if that is done, then how
can I terminate the second child as well ?

Thanks in advance.

Reply via email to