Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by cLive ;-) (Prior)
on Aug 31, 2015 at 15:04 UTC ( #1140543=note: print w/replies, xml ) Need Help??


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

It was the not finding "prince" that caused it to fail (pretty much what aitap said).

Intuitively, I would think the open should fail if the executable being piped to can't be found, but that wasn't the case.

I added a test for the print, and that appears to return true.

So, what I have is:

ok 3 - Opened pipe ok 4 - Piped content to prince not ok 5 - Closed pipe

I'm wondering if an assumption is made internally about piping to the executable until Perl receives a return value on closing?!?

Replies are listed 'Best First'.
Re^4: Can't close pipe to invalid process
by BrowserUk (Patriarch) on Aug 31, 2015 at 16:25 UTC
    I'm wondering if an assumption is made internally about piping to the executable until Perl receives a return value on closing?!?

    Looking back at what you're sending down the pipe; it is way less than the typical 4kb buffer size; which means nothing will be sent until you try to close, at which point it will attempt to flush the buffer through and it is only at that point that the broken pipe will be discovered.

    You could verify that conjecture by trying to print more data to the pipe:

    my $fh; ok( open($fh, "|-", "prince - 2>/dev/null $test_file"), "Open +$test_file for writing" ); print( $fh 'x' x 1024 ) or die "Print failed at $_ with $!" fo +r 1 .. 5; ok( close($fh), "Close $test_file");

    My guess is that will fail at the 4th or 5th iteration with "Broken pipe".


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
    I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2022-08-14 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?