mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 15:35:41 +00:00

Verify that worker.process.kill() can terminate a cluster worker stuck in an infinite loop. PR-URL: https://github.com/nodejs/node/pull/23165 Fixes: https://github.com/nodejs/node/issues/22703 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
22 lines
574 B
JavaScript
22 lines
574 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const cluster = require('cluster');
|
|
const assert = require('assert');
|
|
|
|
if (cluster.isMaster) {
|
|
const worker = cluster.fork();
|
|
|
|
worker.on('online', common.mustCall(() => {
|
|
// Use worker.process.kill() instead of worker.kill() because the latter
|
|
// waits for a graceful disconnect, which will never happen.
|
|
worker.process.kill();
|
|
}));
|
|
|
|
worker.on('exit', common.mustCall((code, signal) => {
|
|
assert.strictEqual(code, null);
|
|
assert.strictEqual(signal, 'SIGTERM');
|
|
}));
|
|
} else {
|
|
while (true) {}
|
|
}
|