1'use strict'; 2const common = require('../common'); 3const net = require('net'); 4const assert = require('assert'); 5const { fork } = require('child_process'); 6 7// This test should end immediately after `unref` is called 8// The pipe will stay open as Node.js completes, thus run in a child process 9// so that tmpdir can be cleaned up. 10 11const tmpdir = require('../common/tmpdir'); 12 13if (process.argv[2] !== 'child') { 14 // Parent 15 tmpdir.refresh(); 16 17 // Run test 18 const child = fork(__filename, ['child'], { stdio: 'inherit' }); 19 child.on('exit', common.mustCall(function(code) { 20 assert.strictEqual(code, 0); 21 })); 22 23 return; 24} 25 26// Child 27const s = net.Server(); 28s.listen(common.PIPE); 29s.unref(); 30