1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const cp = require('child_process');
5const fixtures = require('../common/fixtures');
6
7const fixture = fixtures.path('empty.js');
8const child = cp.fork(fixture);
9
10child.on('close', common.mustCall((code, signal) => {
11  assert.strictEqual(code, 0);
12  assert.strictEqual(signal, null);
13
14  const testError = common.expectsError({
15    name: 'Error',
16    message: 'Channel closed',
17    code: 'ERR_IPC_CHANNEL_CLOSED'
18  }, 2);
19
20  child.on('error', testError);
21
22  {
23    const result = child.send('ping');
24    assert.strictEqual(result, false);
25  }
26
27  {
28    const result = child.send('pong', testError);
29    assert.strictEqual(result, false);
30  }
31}));
32