Hi, Tim.
You write
I want to spawn a child process and have *all* output go to the same file.
>
>
Why? (looking down the thred...)
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).
>
Fine.
It is right there in docs: "Example of detaching a long-running process and
redirecting its output to a file"
Like you've found:
> So I guess I have to explicitly truncate the file first, then open two
> append streams to it?
>
> //fs.closeSync(fs.openSync('/tmp/output.log', 'w'));
> var output = fs.openSync('/tmp/output.log', 'a');
> var output2 = fs.openSync('/tmp/output.log', 'a');
> childProcess.spawn('bash', ['-c', 'echo STOUT; echo STDERR >&2; echo
> DONE;'], {stdio: ['ignore', output, output2]});
>
>
Works on both MS Windows and */Linux (tested). It even looks symmetrical
(by action, not by value, but anyway)
Thus, why not to just read docs and use it, instead of remembering all that
legacy tricks on other languages, platforms, etc.?
BTW, this works on MS Windows without overlapping: {stdio: ['ignore',
output, output]}...
_______
--
--
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.