Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Detect whether a writeable filehandle has closed?

by haukex (Archbishop)
on Jan 13, 2021 at 17:45 UTC ( [id://11126856]=note: print w/replies, xml ) Need Help??


in reply to Detect whether a writeable filehandle has closed?

I'm not sure at the moment if this works for pipes, but you could try checking the return value of fileno.

  • Comment on Re: Detect whether a writeable filehandle has closed?

Replies are listed 'Best First'.
Re^2: Detect whether a writeable filehandle has closed?
by jdporter (Paladin) on Jan 13, 2021 at 18:03 UTC

    Are you suggesting that that might be able to detect a filehandle "gone bad"? My problem is not that the open fails, but that the filehandle goes bad (apparently being closed by the child) some time after opening.

      Are you suggesting that that might be able to detect a filehandle "gone bad"? My problem is not that the open fails, but that the filehandle goes bad (apparently being closed by the child) some time after opening.

      I see now what you mean, my assumption from the "Detect whether a writeable filehandle has closed?" was that you're looking at the filehandle on your end, but you're asking about the other end of the pipe. Sorry, fileno doesn't help with that, only if your filehandle closes (i.e. $pipe in your example here).

      You might want to look at IPC::Run, it has a pumpable method that seems more like what you're asking for. I've also used its pump_nb method inside an eval to detect when a child process has gone bad.

      Minor edits.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found