jalebie has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I have the following perl script, which uses a basic fork command to launch parallel processes. For some reason the fork command seems to fail on WIN2000. Is the fork command even supported for Win2000/MS-DOS in perl. If it is please let me know whats wrong with my code. It works fine on UNIX.
eval 'exec ${PWPROD}/${ARCH}/perl/bin/perl -w -S $0 ${1+"$@"}' if 0; use strict; my $pid = fork; if ($pid == 0) { # child print "in child process \n"; exit 1; } elsif ( $pid > 0 ) { # parent print "in parent \n"; } else { # fork error print "fork command failed with code $pid \n"; exit 1; }


On UNIX I get the expected rsult as follows:
in parent in child process
On Win2000 I get the following error message:
fork command failed with code -1214 in child process

Replies are listed 'Best First'.
Re: Fork cmd in perl
by wog (Curate) on Sep 17, 2001 at 22:57 UTC
    Perl's fork emulation on Windows generates negative pseudo-process IDs which are valid. fork will only return undef if there is an error, a negative number does not indicate an error, so you shouldn't treat it as such.

    update: for more information on Windows fork emulation you can of course check out perlfork.