mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
0633e9a0b5
PR-URL: https://github.com/nodejs/node/pull/44045 Reviewed-By: James M Snell <jasnell@gmail.com>
22 lines
633 B
JavaScript
22 lines
633 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cluster = require('cluster');
|
|
const { ChildProcess } = require('child_process');
|
|
const dc = require('diagnostics_channel');
|
|
|
|
if (cluster.isPrimary) {
|
|
dc.subscribe('child_process', common.mustCall(({ process }) => {
|
|
assert.strictEqual(process instanceof ChildProcess, true);
|
|
}));
|
|
const worker = cluster.fork();
|
|
worker.on('online', common.mustCall(() => {
|
|
worker.send('disconnect');
|
|
}));
|
|
} else {
|
|
process.on('message', common.mustCall((msg) => {
|
|
assert.strictEqual(msg, 'disconnect');
|
|
process.disconnect();
|
|
}));
|
|
}
|