Re: [nodejs] How to have childprocess.stdout printed without delay

13 views
Skip to first unread message

Matt

unread,
Feb 19, 2016, 8:58:40 AM2/19/16
to nod...@googlegroups.com
Convince the command not to buffer. It is probably written such that if it thinks stdout is a tty it line-buffers, but if stdout is a pipe it block-buffers.

In perl you do this via "$|++". The app may have a command-line flag for it if you're lucky.

On Tue, Feb 16, 2016 at 5:50 PM, Hoa Phan <s506...@gmail.com> wrote:
So I have something like:

function startWebApp(command, arguments) {
var childProc = require("child_process").exec(command, arguments);
childProc.stdout.pipe(process.stdout);
childProc.on("exit", process.exit);
}

The output seems to be buffered and result seems to be delayed, it only printed after some interval compared to when I runs the "command" directly in bash.
Is there a way around this.

Thanks and Regards,


--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/b2220317-a2fa-47d3-bd7e-5c6b005532d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages