Fork a Child Process in Perl
Spawn a child process with fork() and wait for it to exit.
Author:
chris
// Language: Perl
#!/usr/bin/perl
use strict;
use warnings;
my $pid = fork();
die "fork failed: $!" unless defined $pid;
if ($pid == 0) {
print "Child PID $$\n";
sleep 1;
exit 0;
} else {
print "Parent waiting on $pid\n";
waitpid($pid, 0);
print "Child exited with $?\n";
}