On Tuesday, October 29, 2013 2:24:17 PM UTC+11, Sam Roberts wrote:
>
> On Mon, Oct 28, 2013 at 5:07 AM, Tim Cuthbertson 
> <[email protected]<javascript:>> 
> wrote: 
> > Thanks for the suggestion, although unfortunately I don't think that 
> would 
> > work for my real scenario. I'm spawning long running tasks, which may 
> > outlive the process that spawned them (which is why I'm directing the 
> output 
> > into a file). Presumably these streams would all stop working / die when 
> my 
> > parent process ends. 
>
> Have you read the docs for child_process.spawn? In particular, for the 
> stdio array? 
>
> It looks like you want option (4), where you open a file, and provide 
> that file to the child proces as 
>
> [ null, f, f], 
>
> so the open file is duped in child to fd 1 and 2 (stdout and stderr). 
>
> Sam 
>

Good point, I missed this in my reading of those docs. It does seem very 
similar to what I tried with passing in the same FD twice, but the docs 
*do* explicitly say it dup()s the fd. Worth a shot, certainly:

    var outpath = '/tmp/output.log';
    var out = fs.createWriteStream(outpath);
    childProcess.spawn('bash', ['-c', 'echo STOUT; echo STDERR >&2; echo 
DONE;'], {stdio: ['ignore', out, out]});

But sadly, I get the same result as when I was passing the same FD twice:

    STOUT
    DONE

Cheers,
 - Tim.

-- 
-- 
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