Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: #8160
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com>
  • Loading branch information
cjihrig committed Aug 20, 2016
commit 7b1b0c4ff0dc6fade57e3192475d285c4fe834ae
28 changes: 28 additions & 0 deletions test/parallel/test-child-process-send-after-close.js
Original file line number Diff line number Diff line change
@@ -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);
}
}));