From 4980517c0c634b9680b2396ec47eb7a98d336160 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Mon, 4 Dec 2017 18:12:59 +0100 Subject: [PATCH] doc: remove IPC channel implementation details IPC messages are more complicated than a simple pipe passing JSON objects separated by new line. This removes inaccurate notes about implementation from the documentation. PR-URL: https://github.com/nodejs/node/pull/17460 Fixes: https://github.com/nodejs/node/issues/16491 Fixes: https://github.com/nodejs/node/issues/17405 Reviewed-By: Jon Moss Reviewed-By: Rich Trott Reviewed-By: Refael Ackermann Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- doc/api/child_process.md | 18 ++++++------------ doc/api/process.md | 11 ++++------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index bda73e4a9b22a5..8b04db57f2e7d2 100755 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -366,8 +366,7 @@ By default, `child_process.fork()` will spawn new Node.js instances using the Node.js processes launched with a custom `execPath` will communicate with the parent process using the file descriptor (fd) identified using the -environment variable `NODE_CHANNEL_FD` on the child process. The input and -output on this fd is expected to be line delimited JSON objects. +environment variable `NODE_CHANNEL_FD` on the child process. *Note*: Unlike the fork(2) POSIX system call, `child_process.fork()` does not clone the current process. @@ -609,9 +608,7 @@ pipes between the parent and child. The value is one of the following: 2. `'ipc'` - Create an IPC channel for passing messages/file descriptors between parent and child. A [`ChildProcess`][] may have at most *one* IPC stdio file descriptor. Setting this option enables the [`subprocess.send()`][] - method. If the child writes JSON messages to this file descriptor, the - [`subprocess.on('message')`][`'message'`] event handler will be triggered in - the parent. If the child is a Node.js process, the presence of an IPC channel + method. If the child is a Node.js process, the presence of an IPC channel will enable [`process.send()`][], [`process.disconnect()`][], [`process.on('disconnect')`][], and [`process.on('message')`] within the child. @@ -933,9 +930,8 @@ added: v0.5.9 The `'message'` event is triggered when a child process uses [`process.send()`][] to send messages. -*Note*: The message goes through JSON serialization and parsing. The resulting -message might not be the same as what is originally sent. See notes in -[the `JSON.stringify()` specification][`JSON.stringify` spec]. +*Note*: The message goes through serialization and parsing. The resulting +message might not be the same as what is originally sent. ### subprocess.channel @@ -1103,9 +1099,8 @@ be used to send messages to the child process. When the child process is a Node.js instance, these messages can be received via the [`process.on('message')`][] event. -*Note*: The message goes through JSON serialization and parsing. The resulting -message might not be the same as what is originally sent. See notes in -[the `JSON.stringify()` specification][`JSON.stringify` spec]. +*Note*: The message goes through serialization and parsing. The resulting +message might not be the same as what is originally sent. For example, in the parent script: @@ -1382,7 +1377,6 @@ unavailable. [`ChildProcess`]: #child_process_child_process [`Error`]: errors.html#errors_class_error [`EventEmitter`]: events.html#events_class_eventemitter -[`JSON.stringify` spec]: https://tc39.github.io/ecma262/#sec-json.stringify [`subprocess.connected`]: #child_process_subprocess_connected [`subprocess.disconnect()`]: #child_process_subprocess_disconnect [`subprocess.kill()`]: #child_process_subprocess_kill_signal diff --git a/doc/api/process.md b/doc/api/process.md index 636ed9a91be17e..8dc4a9106e7c7a 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -94,9 +94,8 @@ The listener callback is invoked with the following arguments: * `sendHandle` {Handle object} a [`net.Socket`][] or [`net.Server`][] object, or undefined. -*Note*: The message goes through JSON serialization and parsing. The resulting -message might not be the same as what is originally sent. See notes in -[the `JSON.stringify()` specification][`JSON.stringify` spec]. +*Note*: The message goes through serialization and parsing. The resulting +message might not be the same as what is originally sent. ### Event: 'rejectionHandled'