You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
547 B
Perl

#!/usr/bin/perl
use warnings;
use strict;
my ( $pid, $pid2 );
$| = 1;
if ( ( $pid = fork() ) && ( $pid2 = fork() ) ) {
print( "I have to wait for my kids.\n" );
my $straggler = waitpid( $pid, 0 );
print( "Finally $straggler finished, now I can go.\n" );
}
elsif ( $pid && defined( $pid2 ) ) {
print( "Kid 2: Mine is not...\n" );
print( "Kid 2: Hey! Wait for me!!!\n" );
exit();
}
elsif ( defined( $pid ) ) {
print( "Kid 1: My parent is very patient...\n" );
}
else {
die( "Forking problems: " );
}