11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// This code triggers an AssertionError on Linux in Node.js 5.3.0 and earlier.
41cb0ef41Sopenharmony_ci// Ref: https://github.com/nodejs/node/issues/4205
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst common = require('../common');
71cb0ef41Sopenharmony_ciif (common.isWindows)
81cb0ef41Sopenharmony_ci  common.skip('This test does not apply to Windows.');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst assert = require('assert');
111cb0ef41Sopenharmony_ciconst net = require('net');
121cb0ef41Sopenharmony_ciconst cluster = require('cluster');
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cicluster.schedulingPolicy = cluster.SCHED_NONE;
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciif (cluster.isPrimary) {
171cb0ef41Sopenharmony_ci  let worker2;
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  const worker1 = cluster.fork();
201cb0ef41Sopenharmony_ci  worker1.on('message', common.mustCall(function() {
211cb0ef41Sopenharmony_ci    worker2 = cluster.fork();
221cb0ef41Sopenharmony_ci    worker1.disconnect();
231cb0ef41Sopenharmony_ci    worker2.on('online', common.mustCall(worker2.disconnect));
241cb0ef41Sopenharmony_ci  }));
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci  cluster.on('exit', common.mustCall(function(worker, code) {
271cb0ef41Sopenharmony_ci    assert.strictEqual(code, 0, `worker exited with error code ${code}`);
281cb0ef41Sopenharmony_ci  }, 2));
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci  return;
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ciconst server = net.createServer();
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ciserver.listen(0, function() {
361cb0ef41Sopenharmony_ci  process.send('listening');
371cb0ef41Sopenharmony_ci});
38