[Melbourne-pm] fork()ing Windows

Sisyphus sisyphus1 at optusnet.com.au
Sun Jul 24 18:16:33 PDT 2005


----- Original Message ----- 
From: "Leigh Sharpe" <lsharpe at pacificwireless.com.au>
To: <melbourne-pm at pm.org>
Sent: Monday, July 25, 2005 10:30 AM
Subject: [Melbourne-pm] fork()ing Windows


Hi All,
 Can anybody tell me what the status of fork() is on windows?
----------------------------

I've been using perl on Win32 for quite some time. I think the status of
fork is still experimental ... but since I've never played with fork on
Win32, I'm hardly qualified to go around making categorical statements about
it. The fork() function is unavailable on Win32 perls built without threads
support - at least that was the case as recently as perl 5.8.3 (which is the
only unthreaded perl I have to test with). That's probably not an issue
since perl on Win32 is usually built with threads support.
Otoh, I know that Win32::Process, which I have used, gives pretty good
milage - though the coding is a little kludgy.

Fwiw, I tried a slightly modified version of the sample you posted (running
on perl 5.6, ActiveState build 810).

use warnings;

for (1..5)
{
    my $pid=fork;
    unless ($pid)
    {
        print "Exiting at Stage 1\n";
        exit;
    }
    my $pid2=fork;
    unless ($pid2)
    {
        print "Exiting at Stage 2\n";
        exit;
    }
    my $pid3=fork;
    unless ($pid3)
    {
        print "Exiting at Stage 3\n";
        exit;
    }
    print "sleeping ...";
    sleep(1);
    print ".. awake\n";
    kill ('USR1',$pid2);
}

__END__

Which produces:

D:\pscrpt>perl try.pl
Exiting at Stage 1
Exiting at Stage 2
Exiting at Stage 3
sleeping ..... awake
Unrecognized signal name "USR1" at try.pl line 26.

At which point the script dies.

The output is exactly the same on perl 5.8.7.

You would probably get more definitive advice regarding fork() from the
perl-win32-users mailing list ( http://aspn.activestate.com/ASPN/Mail/ )
than you will from me :-)

Hth.

Cheers,
Rob



More information about the Melbourne-pm mailing list