Hi,

I have found a bug in the fork() implementation on Win32 when using a handle
that has a PerlIO::via layer.

My test fails with both ActivePerl 5.10.0.1003 and StrawberryPerl 5.10 (Jan
29 2009 20:56:38).
It works on Unix.

Here is my test case (bug-perlio-via-Pid.pl):
--------8<--------8<--------8<--------8<--------8<--------8<--------
use strict;
use warnings;

{
    package PerlIO::via::Pid;
    sub PUSHED { bless \*PUSHED, $_[0] }
    sub WRITE
    {
        (print {$_[2]} "[$$] $_[1]") ? length($_[1]) : -1;
    }
    1;
}

unless (@ARGV) {
    binmode(STDOUT, ':via(Pid)');
}

print "Start $$\n";

if (fork()) {
    print "Parent $$\n";
} else {
    print "Child $$\n";
}
--------8<--------8<--------8<--------8<--------8<--------8<--------

Here is the program output:
--------8<--------8<--------8<--------8<--------8<--------8<--------
[SB] T:\>perl bug-perlio-via-Pid.pl no-layer
Start 3632
Parent 3632
Child -2420

[SB] T:\>perl bug-perlio-via-Pid.pl
[2044] Start 2044
No package specified at bug-perlio-via-Pid.pl line 20.
[2044] Parent 2044
print() on unopened filehandle STDOUT at bug-perlio-via-Pid.pl line 23.
--------8<--------8<--------8<--------8<--------8<--------8<--------

Olivier Mengué.

Reply via email to