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
486 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 = wait();
print( "Finally $straggler finished, now I can go.\n" );
}
elsif ( $pid && defined( $pid2 ) ) {
print( "Kid 2: So is mine...\n" );
exit();
}
elsif ( defined( $pid ) ) {
print( "Kid 1: My parent is patient...\n" );
}
else {
die( "Forking problems: " );
}