summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-kill-infinite-loop.js
blob: f53e6e3976ec28524b27aab18c7daa2a84f1ccc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'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) {}
}