Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Can't close pipe to invalid process

by ikegami (Patriarch)
on Aug 31, 2015 at 18:00 UTC ( [id://1140557]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Can't close pipe to invalid process
in thread Can't close pipe to invalid process

That's completely wrong.

1. Closing one end of a pipe doesn't cause close on the other end to return an error.

$ perl -E' pipe($r, $w) or die $!; close($w) or die $!; close($r) or die $!; say "ok"; ' ok

2. Closing a pipe created by open(my $fh, '|-', ...) reads the process (calls wait). It's very appropriate to do this, whether the pipe is closed or not. Closing such a handle returns the same thing as system.

$ perl -E' open(my $fh, "|-", "perl", "-e", "exit 123") or die $!; close($fh); die("$!\n") if $? == -1; die("Signal ".( $? & 0x7F )."\n") if $? & 0x7F; die("Error ".( $? >> 8 )."\n") if $? >> 8; say "ok"; ' Error 123

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2025-03-26 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (68 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.