-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't read from process.stdin.fd in Node.js 6.10 #7439
Comments
There is a long and technical explanation but the summary is that, on OS X, Aside: the I'll close the issue as working-as-intended but let me know if you have more questions. |
Aah, I didn't realise it was an undocumented API! Thanks for clearing that up! |
I get the same error on Linux, not just on Mac, is there no way to directly read from STDIN fd, without going through streams? |
@CMCDragonkai You can |
@bnoordhuis What kind of mixed results are you implying? I figured to use process.stdin.fd on Windows, but on Linux/Mac to open /dev/fd/0 instead. |
@CMCDragonkai With one resource and two readers it's indeterminate who reads what: reader A may read the first line, B the second line, A the third line, etc. |
In my case, that's the expected behaviour. Thanks! |
It is currently documented: https://nodejs.org/api/process.html#process_process_stdin_fd |
I don't think it was documented when I raised the issue, but it's worth noting that a lot has changed since version 6. |
I'm currently writing a simple CLI with Node.js 6.1.0. Here's an example of how I'm trying to read from stdin:
When running this on OS X Yosemite (10.10.5),
node
exits withError: EAGAIN: resource temporarily unavailable, read
. Interestingly, it works if I replaceprocess.stdin.fd
withfs.openSync('/dev/stdin', 'rs')
.Another point of interest is that I can use
process.stdin.fd
with Node.js 4.4.0 as long as I replaceBuffer.alloc
with a call to the deprecatedBuffer
constructor vianew
.Finally,
process.stdin.fd
andfs.openSync('/dev/stdin', 'rs')
don't return the same FDNumber
; on my system, the return values are 0 and 14 respectively.Am | missing something obvious or is there a potentially bug with
process.stdin.fd
on OS X/Node.js 6?Thanks for your time,
James
The text was updated successfully, but these errors were encountered: