mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Closing the underlying resource completely has the unwanted side effect that the stream can no longer be used at all, including passing it to other child processes. What we want to avoid is accidentally reading from the stream; accordingly, it should be sufficient to stop its readable side manually, and otherwise leave the underlying resource intact. Fixes: https://github.com/nodejs/node/issues/27097 Refs: https://github.com/nodejs/node/pull/21209 PR-URL: https://github.com/nodejs/node/pull/27373 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
24 lines
554 B
JavaScript
24 lines
554 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { spawn } = require('child_process');
|
|
const net = require('net');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
const server = net.createServer((conn) => {
|
|
spawn(process.execPath, ['-v'], {
|
|
stdio: ['ignore', conn, 'ignore']
|
|
}).on('close', common.mustCall(() => {
|
|
conn.end();
|
|
}));
|
|
}).listen(common.PIPE, () => {
|
|
const client = net.connect(common.PIPE, common.mustCall());
|
|
client.on('data', () => {
|
|
client.end(() => {
|
|
server.close();
|
|
});
|
|
});
|
|
});
|