11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst cluster = require('cluster'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cicluster.schedulingPolicy = cluster.SCHED_NONE; 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciif (cluster.isPrimary) { 91cb0ef41Sopenharmony_ci const worker1 = cluster.fork(); 101cb0ef41Sopenharmony_ci worker1.on('listening', common.mustCall(() => { 111cb0ef41Sopenharmony_ci const worker2 = cluster.fork(); 121cb0ef41Sopenharmony_ci worker2.on('exit', (code, signal) => { 131cb0ef41Sopenharmony_ci assert.strictEqual(code, 0, 141cb0ef41Sopenharmony_ci 'worker2 did not exit normally. ' + 151cb0ef41Sopenharmony_ci `exited with code ${code}`); 161cb0ef41Sopenharmony_ci assert.strictEqual(signal, null, 171cb0ef41Sopenharmony_ci 'worker2 did not exit normally. ' + 181cb0ef41Sopenharmony_ci `exited with signal ${signal}`); 191cb0ef41Sopenharmony_ci worker1.disconnect(); 201cb0ef41Sopenharmony_ci }); 211cb0ef41Sopenharmony_ci })); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci worker1.on('exit', common.mustCall((code, signal) => { 241cb0ef41Sopenharmony_ci assert.strictEqual(code, 0, 251cb0ef41Sopenharmony_ci 'worker1 did not exit normally. ' + 261cb0ef41Sopenharmony_ci `exited with code ${code}`); 271cb0ef41Sopenharmony_ci assert.strictEqual(signal, null, 281cb0ef41Sopenharmony_ci 'worker1 did not exit normally. ' + 291cb0ef41Sopenharmony_ci `exited with signal ${signal}`); 301cb0ef41Sopenharmony_ci })); 311cb0ef41Sopenharmony_ci} else { 321cb0ef41Sopenharmony_ci const net = require('net'); 331cb0ef41Sopenharmony_ci const server = net.createServer(); 341cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 351cb0ef41Sopenharmony_ci if (cluster.worker.id === 2) { 361cb0ef41Sopenharmony_ci server.close(() => { 371cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 381cb0ef41Sopenharmony_ci server.close(() => { 391cb0ef41Sopenharmony_ci process.disconnect(); 401cb0ef41Sopenharmony_ci }); 411cb0ef41Sopenharmony_ci })); 421cb0ef41Sopenharmony_ci }); 431cb0ef41Sopenharmony_ci } 441cb0ef41Sopenharmony_ci })); 451cb0ef41Sopenharmony_ci} 46