-
Notifications
You must be signed in to change notification settings - Fork 8
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
Why is there an extra -1
attached to the end of input?
#1
Comments
Thank you for playing with xterm-pty! TBH I don't remember my intention precisely, so I could be wrong, but I think it represents "IO flush". The Emscripten runtime reads from stdin by calling xterm-pty/src/emscriptenHack.ts Line 37 in 06e1c8f
However, we may add |
Thanks for the reply! I couldn't find any reference regarding "IO flush", however it could be due to an emscripten quirk. On a slightly different topic: I've been recently building a WASM-powered PTY app, and I run into xterm-pty. While currently xterm-pty works with emscripten based apps, there's nothing really stopping us using it to run a WASM app. In the WASM world, there's a de-facto standard named WASI, which defines a set of ABIs for WASM apps, including IO operations and so on. So I started playing out an idea: what if I build a WASI polyfill connecting a WASM PTY app to xterm-pty? After a few days' hacking, I do have some initial code in this repository. I also have a demo at here, it basically compiles linenoise using wasi-sdk, and run it in the browser. For more technical details into the demo, you can check out the source code at here. Note apart from this C demo, I do have a relatively larger demo, where I compile ckb-vm, a full RISC-V interpreter (written in Rust) to WASM and run it via xterm-pty in the browser. I'm still cleaning up the code for this, hopefully I can release it in a couple of days. However, it does require some changes to xterm-pty to support this new WASI use case, I have the changes put together in this commit. Specifically, the changes include:
With the background explained above, I do have some questions for you:
Again, thanks for such an interesting project! Look forward to seeing it continues to grow. |
And here's the Rust based RISC-V interpreter I'm talking about: https://github.com/xxuejie/instant-riscv |
Previously, ttyServer.onRead returned -1 which meant IO flush or EOF. This is for the behavior of get_char of Emscripten internal. However, this hack is Emscripten-specific, so it would be good to handle it in emscriptenHack instead of ttyServer. Fixes #1
@xxuejie Sorry for the late reply!
Yes, it is very Emscripten-specific. You can see the comment "get_char has 3 particular return values: ... c.) null to signal an EOF" in get_char of Emscripten. However, I'd like to handle the hack in emscriptenHack, and keep ttyServer plain. I merged #2 so now the hack was removed from ttyServer.
I am okay for the existing workerTool to export Termios, but do you want to have a separate entrypoint? That will be fine if the new entrypoint includes a lot of polyfills for WASI.
I think this will be fixed by #2.
I like the idea, and I actually want to run a Ruby interpreter built with WASI with xterm-pty. It would be nice if it could be integrated with the existing wasi runtime like Wasmer JS.
Welcome, of course! |
I was toying around with this project, and I noticed that sometimes, the input data gathered from xterm/pty side, seems to contain an extra
-1
.Upon some investigation I managed to narrow down to this line, so the question is: why appending an extra
-1
here? Is this due to some historic conventions?Many thanks!
The text was updated successfully, but these errors were encountered: