in reply to Windows and pipes that don't close

That means that you aren't managing to get all of the dup()s of the file handle closed.

I wouldn't be surprised if $^F has some problems in Win32 (though perlport does not mention it).

See SetHandleInformation and HANDLE_FLAG_INHERIT in Win32API::File.

- tye        

  • Comment on Re: Windows and pipes that don't close (close-on-exec)

Replies are listed 'Best First'.
Re^2: Windows and pipes that don't close (close-on-exec)
by salva (Canon) on Dec 10, 2014 at 17:03 UTC
    Unsetting HANDLE_FLAG_INHERIT works!
    open my $oldin, '<&', \*STDIN or die $!; pipe my($r), my ($w) or die $!; open STDIN, '<&', $r or die $!; my $wh = FdGetOsFHandle(fileno $w); SetHandleInformation($wh, HANDLE_FLAG_INHERIT, 0); my $pid = system 1, 'perl -ne print'; print "pid: $pid\n"; close STDIN or die $!; open STDIN, '<&', $oldin; close $r or die $!; print {$w} "hello world! ($_)\n" for 0..9; close $w or die $!; print "waiting for slave process\n"; waitpid $pid, 0 or die $!