-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix isatty() under NODERAWFS
#26530
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
Fix isatty() under NODERAWFS
#26530
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ addToLibrary({ | |
| if (!ENVIRONMENT_IS_NODE) { | ||
| throw new Error("NODERAWFS is currently only supported on Node.js environment.") | ||
| } | ||
| var nodeTTY = require('node:tty'); | ||
| function _wrapNodeError(func) { | ||
| return (...args) => { | ||
| try { | ||
|
|
@@ -64,11 +65,10 @@ addToLibrary({ | |
| return { path, node: { id: st.ino, mode, node_ops: NODERAWFS, path }}; | ||
| }, | ||
| createStandardStreams() { | ||
| // FIXME: tty is set to true to appease isatty(), the underlying ioctl syscalls still need to be implemented, see issue #22264. | ||
| FS.createStream({ nfd: 0, position: 0, path: '/dev/stdin', flags: 0, tty: true, seekable: false }, 0); | ||
| FS.createStream({ nfd: 0, position: 0, path: '/dev/stdin', flags: 0, seekable: false }, 0); | ||
| var paths = [,'/dev/stdout', '/dev/stderr']; | ||
| for (var i = 1; i < 3; i++) { | ||
| FS.createStream({ nfd: i, position: 0, path: paths[i], flags: {{{ cDefs.O_TRUNC | cDefs.O_CREAT | cDefs.O_WRONLY }}}, tty: true, seekable: false }, i); | ||
| FS.createStream({ nfd: i, position: 0, path: paths[i], flags: {{{ cDefs.O_TRUNC | cDefs.O_CREAT | cDefs.O_WRONLY }}}, seekable: false }, i); | ||
| } | ||
| }, | ||
| // generic function for all node creation | ||
|
|
@@ -179,10 +179,11 @@ addToLibrary({ | |
| createStream(stream, fd) { | ||
| // Call the original FS.createStream | ||
| var rtn = VFS.createStream(stream, fd); | ||
| if (typeof rtn.shared.refcnt == 'undefined') { | ||
| rtn.shared.refcnt = 1; | ||
| } else { | ||
| // Detect PIPEFS streams and skip the refcnt/tty initialization in that case. | ||
| if (!stream.stream_ops) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this change do?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just simplified the code a little here. The presence of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a comment here. |
||
| rtn.shared.refcnt ??= 0; | ||
| rtn.shared.refcnt++; | ||
| rtn.tty = nodeTTY.isatty(rtn.nfd); | ||
| } | ||
| return rtn; | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it correct to remove "tty: true" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
FS.createStreamautomatically sets the tty property now, with the correct value.