summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2016-04-01 22:23:16 -0700
committerJames M Snell <jasnell@gmail.com>2016-04-02 19:37:58 -0700
commit6fd26dcc20e9189082f9fda1014f483bf4408fe7 (patch)
tree203b3dea288011ae264f6c135d43b81316c35054 /doc
parentba0b769c7b17078b68b4ec8309dc06ac36faae96 (diff)
downloadandroid-node-v8-6fd26dcc20e9189082f9fda1014f483bf4408fe7.tar.gz
android-node-v8-6fd26dcc20e9189082f9fda1014f483bf4408fe7.tar.bz2
android-node-v8-6fd26dcc20e9189082f9fda1014f483bf4408fe7.zip
doc: clarify stdout/stderr arguments to callback
Clarify that the arguments to child_process.execFile and child_process.exec callback can be Buffer or strings. Fixes: https://github.com/nodejs/node/issues/3389 PR-URL: https://github.com/nodejs/node/pull/6015 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/child_process.markdown22
1 files changed, 18 insertions, 4 deletions
diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown
index bb7dcf4560..aaaa002fb4 100644
--- a/doc/api/child_process.markdown
+++ b/doc/api/child_process.markdown
@@ -131,8 +131,8 @@ exec('my.bat', (err, stdout, stderr) => {
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
* `callback` {Function} called with the output when process terminates
* `error` {Error}
- * `stdout` {Buffer}
- * `stderr` {Buffer}
+ * `stdout` {String|Buffer}
+ * `stderr` {String|Buffer}
* Return: {ChildProcess}
Spawns a shell then executes the `command` within that shell, buffering any
@@ -157,6 +157,13 @@ the exit code of the child process while `error.signal` will be set to the
signal that terminated the process. Any exit code other than `0` is considered
to be an error.
+The `stdout` and `stderr` arguments passed to the callback will contain the
+stdout and stderr output of the child process. By default, Node.js will decode
+the output as UTF-8 and pass strings to the callback. The `encoding` option
+can be used to specify the character encoding used to decode the stdout and
+stderr output. If `encoding` is `'buffer'`, `Buffer` objects will be passed to
+the callback instead.
+
The `options` argument may be passed as the second argument to customize how
the process is spawned. The default options are:
@@ -198,8 +205,8 @@ replace the existing process and uses a shell to execute the command.*
* `gid` {Number} Sets the group identity of the process. (See setgid(2).)
* `callback` {Function} called with the output when process terminates
* `error` {Error}
- * `stdout` {Buffer}
- * `stderr` {Buffer}
+ * `stdout` {String|Buffer}
+ * `stderr` {String|Buffer}
* Return: {ChildProcess}
The `child_process.execFile()` function is similar to [`child_process.exec()`][]
@@ -220,6 +227,13 @@ const child = execFile('node', ['--version'], (error, stdout, stderr) => {
});
```
+The `stdout` and `stderr` arguments passed to the callback will contain the
+stdout and stderr output of the child process. By default, Node.js will decode
+the output as UTF-8 and pass strings to the callback. The `encoding` option
+can be used to specify the character encoding used to decode the stdout and
+stderr output. If `encoding` is `'buffer'`, `Buffer` objects will be passed to
+the callback instead.
+
### child_process.fork(modulePath[, args][, options])
* `modulePath` {String} The module to run in the child