Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by tye (Sage)
on Dec 10, 2014 at 16:27 UTC ( [id://1109932]=note: print w/replies, xml ) Need Help??


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 $!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1109932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 12:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found