On Fri, Mar 29, 2013 at 7:54 AM, Andrew Hart <[email protected]> wrote:
> I've been trying to use and understand the (new) streams interface, but I
> don't understand when node will or won't terminate my program.
>
> Here are the simplest two cases which are currently confusing me. Why might
> these behave differently? Is it a bug?
>
> node -e 'process.stdin.pipe(process.stdout);
> process.nextTick(function(){process.stdin.unpipe();});'
> node -e 'process.stdin.pipe(process.stdout);
> setTimeout(function(){process.stdin.unpipe();}, 0);'
>
> I know nextTick and setTimeout differ, but in this case I don't understand
> why they aren't equivalent.
>
> The setTimeout one terminates immediately; the other waits for some input,
> does NOT echo it, then terminates.
>
> I'm running a local build of v0.10.2 on a debian squeeze amd64 VM.
>
> Bonus example:
> node -e 'process.stdin.pipe(process.stdout);
> setTimeout(function(){process.stdin.unpipe();}, 10000);'
>
> This one echos its input until the timeout fires. Then it waits for
> ADDITIONAL input which it does NOT echo; then it terminates.
>
> Thanks,
> Andrew

The setTimeout(0) thing is a bug that's fixed in v0.10.2.  I'm
guessing you're running a -pre build that doesn't have the fix.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to