diff --git a/test/parallel/test-cluster-worker-disconnect.js b/test/parallel/test-cluster-worker-disconnect.js index 431fe716759581..4a059558a670a1 100644 --- a/test/parallel/test-cluster-worker-disconnect.js +++ b/test/parallel/test-cluster-worker-disconnect.js @@ -1,8 +1,6 @@ var common = require('../common'); var assert = require('assert'); var cluster = require('cluster'); -var fs = require('fs'); -var path = require('path'); if (cluster.isWorker) { var http = require('http'); @@ -10,9 +8,8 @@ if (cluster.isWorker) { }).listen(common.PORT, '127.0.0.1'); - // Save flag-file on disconnect cluster.worker.on('disconnect', function(){ - fs.writeFileSync(path.join(__dirname, process.pid + ''), ''); + process.exit(42); }); } else if (cluster.isMaster) { @@ -67,17 +64,10 @@ if (cluster.isWorker) { }); // Check that the worker died - worker.once('exit', function() { + worker.once('exit', function(code) { checks.worker.emitExit = true; checks.worker.died = !alive(worker.process.pid); - - var flagFile = path.join(__dirname, worker.process.pid + ''); - checks.worker.emitDisconnectInsideWorker = fs.existsSync(flagFile); - - // cleanup - if (checks.worker.emitDisconnectInsideWorker) { - fs.unlinkSync(flagFile); - } + checks.worker.emitDisconnectInsideWorker = code === 42; process.nextTick(function() { process.exit(0);