0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-child-process-server-close.js

21 lines
504 B
JavaScript
Raw Normal View History

'use strict';
const common = require('../common');
const { spawn } = require('child_process');
const net = require('net');
const server = net.createServer((conn) => {
conn.on('close', common.mustCall());
spawn(process.execPath, ['-v'], {
stdio: ['ignore', conn, 'ignore']
}).on('close', common.mustCall());
}).listen(common.PIPE, () => {
const client = net.connect(common.PIPE, common.mustCall());
client.on('data', () => {
client.end(() => {
server.close();
});
});
});