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

Re^3: pipe fork win32

by BrowserUk (Pope)
on Aug 26, 2012 at 03:24 UTC ( #989778=note: print w/ replies, xml ) Need Help??


in reply to Re^2: pipe fork win32
in thread pipe fork win32

I read select but why?

All the debuf() does is apply $|++ to $parent, thus making the handle line-buffered rather than block buffered.

Hence, the \n in print $parent "exit now\r\n\r"; causes the buffer to be flushed through and the read then completes.

(BTW: The \rs do nothing! As the pipe is in text mode, the \n will be translated to \cM\cJ on write and then back to \cJ when read back.)

why would changing the default handle affect it?

if you look closely at debuf(), it selects the handle ($parent) that is passed to it; does the $++ whilst that handle is selected, and then re-selects the original default handle. Ie. It is equivalent to:

sub debuf{ my $old = select( $_[0] ); $|++; select( $old } }

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.

The start of some sanity?

/code


Comment on Re^3: pipe fork win32
Select or Download Code
Re^4: pipe fork win32
by bulk88 (Priest) on Aug 26, 2012 at 19:36 UTC
    While both solutions of yours work, I am going to use this solution, it seems the most reliable (compared to guessing the IO buffer size of day). Thanks.
      I am going to use this solution, it seems the most reliable (compared to guessing the IO buffer size of day).

      Agreed.

      The string x nnn wasn't really intended as a solution, just a demonstration of the cause.

      Switching to line buffering for 'interactive communications' is the solution.


      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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2014-09-20 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls