From 498238f46279ab56406f7192cefe0a57b896de12 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 18 Aug 2016 12:11:36 -0400 Subject: [PATCH] test: test sending over a closed IPC channel This commit adds a test that attempts to send data over an IPC channel once it has been closed. PR-URL: https://github.com/nodejs/node/pull/8160 Reviewed-By: Rich Trott Reviewed-By: Santiago Gimeno Reviewed-By: Claudio Rodriguez --- .../test-child-process-send-after-close.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/parallel/test-child-process-send-after-close.js diff --git a/test/parallel/test-child-process-send-after-close.js b/test/parallel/test-child-process-send-after-close.js new file mode 100644 index 0000000000..78cf3b6697 --- /dev/null +++ b/test/parallel/test-child-process-send-after-close.js @@ -0,0 +1,28 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); +const path = require('path'); +const fixture = path.join(common.fixturesDir, 'empty.js'); +const child = cp.fork(fixture); + +child.on('close', common.mustCall((code, signal) => { + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + + function testError(err) { + assert.strictEqual(err.message, 'channel closed'); + } + + child.on('error', common.mustCall(testError)); + + { + const result = child.send('ping'); + assert.strictEqual(result, false); + } + + { + const result = child.send('pong', common.mustCall(testError)); + assert.strictEqual(result, false); + } +}));