test stdio closed

This commit is contained in:
chloe caruso
2025-01-19 00:29:50 -08:00
parent 237a568dc7
commit 809ff5e6c2
3 changed files with 4 additions and 7 deletions

View File

@@ -29,7 +29,7 @@ export function getStdioWriteStream(fd) {
let stream;
if (tty.isatty(fd)) {
stream = new tty.WriteStream(fd);
stream = new tty.WriteStream(null, { fd });
// TODO: this is the wrong place for this property.
// but the TTY is technically duplex
// see test-fs-syncwritestream.js
@@ -40,7 +40,7 @@ export function getStdioWriteStream(fd) {
stream._type = "tty";
} else {
const fs = require("node:fs");
stream = new fs.WriteStream(fd, { autoClose: false, fd });
stream = new fs.WriteStream(null, { autoClose: false, fd });
stream.readable = false;
stream._type = "fs";
}
@@ -125,7 +125,7 @@ export function getStdinStream(fd) {
const tty = require("node:tty");
const ReadStream = tty.isatty(fd) ? tty.ReadStream : require("node:fs").ReadStream;
const stream = new ReadStream(fd);
const stream = new ReadStream(null, { fd });
const originalOn = stream.on;

View File

@@ -10,10 +10,7 @@ function ReadStream(fd) {
if (!(this instanceof ReadStream)) {
return new ReadStream(fd);
}
if (fd >> 0 !== fd || fd < 0) throw new RangeError("fd must be a positive integer");
require("node:fs").ReadStream.$apply(this, ["", { fd }]);
this.isRaw = false;
this.isTTY = true;
}
@@ -79,7 +76,6 @@ Object.defineProperty(ReadStream, "prototype", {
function WriteStream(fd) {
if (!(this instanceof WriteStream)) return new WriteStream(fd);
if (fd >> 0 !== fd || fd < 0) throw new RangeError("fd must be a positive integer");
const stream = require("node:fs").WriteStream.$call(this, "", { fd });

View File

@@ -20,6 +20,7 @@ if (common.isWindows) {
proc.on('exit', common.mustCall(function(exitCode) {
assert.strictEqual(exitCode, 0);
}));
proc.stderr.pipe(process.stderr);
return;
}