Help for this page

Select Code to Download


  1. or download this
        if (my $pid = fork) { # $pid defined and !=0 -->parent
            ++$forkcount;
    ...
            close $IN;
            defined $pid and exit(0); # $pid==0 -->child, must exit itself
        }
    
  2. or download this
    my $pid=fork() // die "Can't fork: $!";
    if ($pid) {
    ...
    } else {
        # child code
    }
    
  3. or download this
    my $pid=fork();
    defined($pid) or die "Can't fork: $!";