You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When clossing the file descriptor zero (stdin), if something is still witten to it Node.js still fetchs that info. Since new file descriptors (both by opening files and/or using the unistd module) start at position 12, seems like Node.js itself is internally duplicating fd 0 (probably in the process.stdin stream, in fact process.stdin.fd is 0 but process.stdin._handle.TTY.fd is 9), making it difficult to manipulate the file descriptors at low level, for example when developing interactive shells like nsh where background tasks should be still running (so spawnSync() is not an option).
> process.stdin.close()
TypeError: process.stdin.close is not a function
at repl:1:15
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:349:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:548:10)
at emitOne (events.js:101:20)
at REPLServer.emit (events.js:188:7)
This is not about process.stdin as a stream, though.
Here is why libuv dup()s the file descriptor – ironically, Node doesn’t use non-blocking TTYs anymore.
I’m not sure there’s much to do here (unless you have concrete suggestions?). If you want the tip, you can use compare the fs.fstat(Sync) outputs to check whether two FDs refer to the same file, or just use process.stdin._handle.fd directly (even though it’s a private API).
This issue has been inactive for sufficiently long that it seems like perhaps it should be closed. Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree. I'm just tidying up and not acting on a super-strong opinion or anything like that.
When clossing the file descriptor zero (
stdin
), if something is still witten to it Node.js still fetchs that info. Since new file descriptors (both by opening files and/or using the unistd module) start at position 12, seems like Node.js itself is internally duplicating fd 0 (probably in theprocess.stdin
stream, in factprocess.stdin.fd
is 0 butprocess.stdin._handle.TTY.fd
is 9), making it difficult to manipulate the file descriptors at low level, for example when developing interactive shells like nsh where background tasks should be still running (sospawnSync()
is not an option).Probably related to #5574.
The text was updated successfully, but these errors were encountered: