programming-examples/perl/SystemFunction/Using fork to create child processes.pl
2019-11-15 12:59:38 +01:00

21 lines
353 B
Perl

#!/usr/bin/perl
use warnings;
use strict;
$| = 1;
my $pid = 0;
if ( $pid = fork() ) {
print( "Parent executing.\n" );
sleep( 2 );
print( "Parent finished.\n" );
}
elsif ( defined( $pid ) ) {
print( "Child executing.\n" );
sleep( 2 );
print( "Child finished.\n" );
exit();
}
else {
die( "Could not fork" );
}