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

Re: Detecting Timeout of piped data

by sierpinski (Chaplain)
on Jul 31, 2011 at 03:17 UTC ( [id://917672]=note: print w/replies, xml ) Need Help??


in reply to Detecting Timeout of piped data

I don't really want to comment on your telemetry problem, because I've never piped one script to another like that (and don't want to give you any wrong info), but I can tell you that the <> basically is STDIN. Any time you are assigning it to a variable, you are reading from STDIN up until a carriage return. Obviously if you have it in a loop like while(my $data = <>) then it'll keep reading until some condition breaks the loop. Hope that helps, if even a bit!

Replies are listed 'Best First'.
Re^2: Detecting Timeout of piped data
by Anonymous Monk on Jul 31, 2011 at 04:56 UTC

    Just to expand on your point, $inLine eq '' will never be true because "\n" != ''

      Shouldn't the chomp between the read and the check remove the \n thereby making $inLine eq ''?

      What I believe ( and certainly could be wrong ) is that the script is just sitting and waiting at $inLine = <>; without ever recieving anything, and so never gets to any of the code that follows except when there is input. I think what I am looking for is something like the <> but with a configurable timeout period.

        I looked before and I looked now and I don't see a chomp is the original code. It could be there but and I'm not seeing it but, yes, chomp would fix that problem.

        As for your analysis that the program is sitting in an idle loop, well, yes, that is the main problem, but I thought sierpinski had already said that.

        Wow, I'm really sorry, I shouldn't be posting when I'm drunk, I thought you were trying to help rather than the guy with the question.

        That said, check out what zentara had to say about alarm. Alternatives might be non-blocking reads and using select with a timeout.

        Again, sorry, I'll just go away and leave you in peace now ;^)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found