Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^6: open2() in Windows

by BrowserUk (Patriarch)
on Jul 23, 2007 at 17:53 UTC ( [id://628284]=note: print w/replies, xml ) Need Help??


in reply to Re^5: open2() in Windows
in thread open2() in Windows

... when the child process stops giving output the while (<READ>) terminates ...

No it doesn't! That's the point.

Unless the child process closes the file handle, and so signals that it's not going to write any more output, while( <READ> ) { ... } will just wait until it writes some more.

Since you are running the child process continuously, it never closes stdout, so the parent's inner read loop will never terminate. Sorry, but that is just the way it is.


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.

Replies are listed 'Best First'.
Re^7: open2() in Windows
by bhaveshbp (Initiate) on Jul 23, 2007 at 17:59 UTC
    Ok I get what you are saying now. If this is the case how come the program hangs at random iterations of the loop usually something around 3500 even up to 5000, and at the same command every time? Also the program ran fine in Unix the way it is now.
      If this is the case ...

      It is. Regardless of the OS.

      ... how come ...

      Best guess. The pseudo-code you are posting is a poor reflection of what your real code is actually doing.

      I understand that you have good reasons for not posting the real code, so here is a suggestion. Make a copy of the real code and cut it down to just the outer and inner loops you are concerned with. Then substitute the perl 'echo' command from my post above:

      my $pid = open2 \*READ, \*WRITE, 'perl -wne "$|++; chomp; print"';

      Run that. It should demonstrate the same behaviours as your real program, though the iterations counts will differ. Once you have verified that it has similar problems, post it here.


      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.

Log In?
Username:
Password:

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

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

    No recent polls found