fork
Creates a child process by duplicating the current process.
Calls POSIX fork(2) to create a new child process. Both parent
and child continue execution from the point of the fork call.
Returns:
undefon failure (fork could not be performed)0in the child process- The child’s PID (positive integer) in the parent process
Synopsis
my $pid = fork();
die "fork failed: $!" unless defined $pid;
if ($pid == 0) {
# child process
exit(0);
} else {
# parent process, $pid is child's PID
waitpid($pid, 0);
}