I got this basic "fork" code right out of the book. It is suppose to wait for both child forks to finish before the parent falls through and excute the code after this "if" statement. But which ever child finishes first the parrent will fall through and finish before all the children are done. So I'm looseing data! Outer wise it woork fine. Can someone tell me why the parrent isn't waiting for both children? The second child does finish a few minutes after all else is done.
if (($pid1 = fork() ) && ($pid2 = fork() )) { print "I have to wait for my kids.\n"; my $strabbler = wait(); print "Finally $strabbler finished, now I can go.\n"; } } elsif ($pid1 && defined($pid2)) { &get_switch($FILE2, $OUT_FILE1, $CDP_OUT_FILE1); exit(); } elsif (defined($pid1)) { &get_switch($FILE1, $OUT_FILE2, $CDP_OUT_FILE2); exit(); } else { die( "Forking problem: "); }
smime.p7s
Description: S/MIME cryptographic signature