Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: IO::Pipe hangs

by BrowserUk (Pope)
on Sep 20, 2012 at 19:14 UTC ( #994735=note: print w/ replies, xml ) Need Help??


in reply to IO::Pipe hangs

Because you haven't emptied the pipe, which means that tasklist is blocked waiting to finish writing to it.

Just closing the pipe won't allow tasklist to end; the pipe won't close until it does. Deadlock.

The answer is to empty the pipe before closing it:

use strict; use warnings; use IO::Pipe; my $cmd = "tasklist"; my $pipe = IO::Pipe->new(); $pipe->reader($cmd); while (my $line = $pipe->getline()) { print $line; last if $line =~ /^smss/; } 1 while $pipe->getline; $pipe->close();

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".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


Comment on Re: IO::Pipe hangs
Download Code
Re^2: IO::Pipe hangs
by Anonymous Monk on Sep 20, 2012 at 19:16 UTC
    OK, thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (18)
As of 2014-07-23 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (144 votes), past polls