mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
743 B
28 lines
743 B
'use strict';
|
|
require('../common');
|
|
var cluster = require('cluster');
|
|
var assert = require('assert');
|
|
|
|
if (cluster.isMaster) {
|
|
var worker = cluster.fork();
|
|
assert.ok(!worker.isDead(),
|
|
'isDead() should return false right after the worker has been ' +
|
|
'created.');
|
|
|
|
worker.on('exit', function() {
|
|
assert.ok(worker.isDead(),
|
|
'After an event has been emitted, ' +
|
|
'isDead should return true');
|
|
});
|
|
|
|
worker.on('message', function(msg) {
|
|
if (msg === 'readyToDie') {
|
|
worker.kill();
|
|
}
|
|
});
|
|
|
|
} else if (cluster.isWorker) {
|
|
assert.ok(!cluster.worker.isDead(),
|
|
'isDead() should return false when called from within a worker');
|
|
process.send('readyToDie');
|
|
}
|
|
|