From 7b0e93738bd9c70b3b226d47e3672e3e1ef22bd7 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 27 Oct 2016 14:36:49 -0400 Subject: [PATCH] child_process: add public API for IPC channel This commit adds a public channel property to ChildProcess. The existing _channel property is aliased to the new property, with the intention of deprecating and removing it in the future. Fixes: https://github.com/nodejs/node/issues/9313 PR-URL: https://github.com/nodejs/node/pull/9322 Reviewed-By: James M Snell Reviewed-By: Sam Roberts --- doc/api/child_process.md | 11 +++++++ doc/api/process.md | 10 ++++++ lib/internal/child_process.js | 32 ++++++++++++------- lib/internal/process/stdio.js | 4 +-- .../test-child-process-fork-regr-gh-2847.js | 4 +-- test/parallel/test-child-process-fork.js | 2 ++ .../test-child-process-recv-handle.js | 4 +-- test/parallel/test-child-process-silent.js | 4 +-- 8 files changed, 51 insertions(+), 20 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index dfe787d6f3cd89..6fe6079d4e84a4 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -776,6 +776,16 @@ added: v0.5.9 The `'message'` event is triggered when a child process uses [`process.send()`][] to send messages. +### child.channel + + +* {Object} A pipe representing the IPC channel to the child process. + +The `child.channel` property is a reference to the child's IPC channel. If no +IPC channel currently exists, this property is `undefined`. + ### child.connected + +If the Node.js process was spawned with an IPC channel (see the +[Child Process][] documentation), the `process.channel` +property is a reference to the IPC channel. If no IPC channel exists, this +property is `undefined`. + ## process.chdir(directory)