Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Fork without functions

  • fork
use strict;
use warnings;

main();

sub main {
    my $pid = fork();
    die "Could not fork" if not defined $pid;

    if (not $pid) {
        print "In child process\n";
        exit;
    }

    print "In parent process\n";
    my $finished = wait();
}