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
In Node.js, the special file descriptors 0, 1, and 2 correspond to stdin, stdout, and stderr. You can write to these file descriptors directly using e.g., fs.writeSync:
It would be awesome if BrowserFS could add support for this. Currently, if you try to the same code above with BrowserFS you get an "EBADF: Invalid file descriptor." error.
FWIW I'm using LocalStorage as a backend, but I think this applies to all backends.
As to why this would be useful, it's a bit complicated. I'm currently working on a project that compiles to WebAssembly. Some low level code in a dependency wants to be able to write directly to these special file descriptors. The low level code was written with Node.js in mind, but if BrowserFS supported these file descriptors, we could use it as a drop in solution. Happy to provide more information if needed. There are probably other applications which could benefit from this as well.
The text was updated successfully, but these errors were encountered:
@albrow BrowserFs doesn't even support stdout/stdin/stderr. As those streams are related to the process, maybe the could be introduced to bfs-process and forwarded to BrowserFS?
@dr-vortex thanks for your reply. It's been a long time since I opened this issue and I'm no longer working on the project that originally prompted me to open it.
At first glance, your suggestion of introducing stdout/stdin/stderr support to bfs-process seems like a good place to start. I also would have been fine with a more crude solution (something like special casing these file descriptors to print text directly via console.log or console.error).
That said, I don't really have a need for this anymore and unless someone else chimes in, you can feel free to close the issue.
@albrow Thanks for the fast reply! I checked it using Node and using the FS API to interact with stdin/stdout/atderr actually results in EBADF... It's not a bug, it's a feature!
In Node.js, the special file descriptors 0, 1, and 2 correspond to stdin, stdout, and stderr. You can write to these file descriptors directly using e.g.,
fs.writeSync
:It would be awesome if BrowserFS could add support for this. Currently, if you try to the same code above with BrowserFS you get an
"EBADF: Invalid file descriptor."
error.I think the right place to start is the
fd2file
method.FWIW I'm using
LocalStorage
as a backend, but I think this applies to all backends.As to why this would be useful, it's a bit complicated. I'm currently working on a project that compiles to WebAssembly. Some low level code in a dependency wants to be able to write directly to these special file descriptors. The low level code was written with Node.js in mind, but if BrowserFS supported these file descriptors, we could use it as a drop in solution. Happy to provide more information if needed. There are probably other applications which could benefit from this as well.
The text was updated successfully, but these errors were encountered: