Skip to content
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

Does the current spec allow for things like ioctl and termios? #42

Closed
torch2424 opened this issue May 23, 2019 · 5 comments
Closed

Does the current spec allow for things like ioctl and termios? #42

torch2424 opened this issue May 23, 2019 · 5 comments
Labels
question Further information is requested

Comments

@torch2424
Copy link
Contributor

torch2424 commented May 23, 2019

Hello,

Context

Been working on a fun little CLI project, to do matrix rain effect using the Wasi bindings, and using wasa.

I'm using Wapm / Wasmer to run my Wasm module.

What I think is the problem

I opened this issue on my project: torch2424/wasm-matrix#1 . Which Essentially comes down to, I can't figure out how to get the terminal size using the current available Wasi bindings.

I think what I would need from Wasi is someway to use a the underlying effect of C's ioctl or termios. Is this something you can do with the current WASI bindings? If so, how? If not, is this planned to be done at some point? I understand that Wasm / Wasi are super young, so no worries if it is planned, not looking for an ETA or anything.

cc @dcode , as I originally opened this at: AssemblyScript/assemblyscript#587 . And cc @binji because we chatted about it earlier today 😂

And thanks for all the hard work! Wasi is super cool / exciting. 😄 Thanks!

@sunfishcode
Copy link
Member

sunfishcode commented May 23, 2019

The short answer is no, this isn't possible within the current WASI API.

Beyond that, there are several things which are unportable about the code, for example:

export const GREEN: string = ESC + "32m";
export const WHITE: string = ESC + "37m";
export const RED: string = ESC + "31m";
export const CYAN: string = ESC + "36m";
export const RESET: string = ESC + "0m";

These assume your program's stdout is connected to an ANSI-style terminal. However, the kind of portability we're aiming for with WASI extends beyond platforms like Unix which tend to have ANSI-style terminal emulation. So while this is a neat program with a unique visual effect, enabling programs that only work on one kind of platform isn't the goal we're really aiming for here.

With WASI, we're really looking at the long term. Enthusiasm and cool demos in the short term are fun, but to make progress towards our ultimate goals we must also distinguish between things which show off what WASI can actually do, and things which reach outside of what WASI can do and give false impressions, and potentially distract from the work needed to reach our goals.

It is likely that in the future WASI will add ways to do color output, cursor positioning, and then also terminal size detection, and so on, and it could conceivably do so in a way that's compatible with ANSI escape codes. If someone is interested in starting a proposal to spell out what functionality would be required, and what the interfaces should be, that'd be a great place to start!

@KronicDeth
Copy link

I’d have to look at their code to be sure, but looking at how JetBrains IDEs or Atom or VSCode handle terminals could show us how to make OS neutral terminal APIs since they all have MacOS, Linux, and Windows support.

@dumblob
Copy link

dumblob commented May 24, 2019

@leonerd could you maybe sketch your view on this? Especially in accordance to the last paragraph in the comment of @sunfishcode above.

@rylev rylev added the question Further information is requested label Jun 3, 2019
@PoignardAzur
Copy link

I’d have to look at their code to be sure, but looking at how JetBrains IDEs or Atom or VSCode handle terminals could show us how to make OS neutral terminal APIs since they all have MacOS, Linux, and Windows support.

I've worked on an IDE plugin for Atom as an end-of-study project.

To spawn an integrated terminal, we used nuclide-prebuilt-libs/pty, which is a precompiled binary of node-pty, which is also what VS-code uses.

As far a compatibility goes, it looks like node-pty is based on the POSIX function forkpty, with bindings to ConPTY for Windows compatibility. I have no idea whether any of this is relevant to WASI.

@sunfishcode
Copy link
Member

The original question has been answered here. If anyone has any further questions, feel free to file new issues!

alexcrichton pushed a commit to alexcrichton/WASI that referenced this issue Jan 19, 2022
* FF WASI submodule and update the machinery

This commit fast-forwards the `WASI` submodule and updates the
relevant the machinery. It also updates `generate_raw::generate`
fn to accept a slice in preparation for multi-module `wasi_ephemeral`.

* Fix generating wasi-ephemeral

* Account for reserved keywords as func names

* Preserve to_snake_case for func names

* Feature-gate wrapper syscall gen for ephemeral

* Handle IntDatatype
alexcrichton pushed a commit to alexcrichton/WASI that referenced this issue Jan 19, 2022
This follows directly from the discussion in WebAssembly#42 where we agreed
that `char8` is essentially a named "alias" to a byte type (`u8`)
and represents a code *unit* (much like `char8_t` in C++20), rather
than a code *point* (as is the case with multi-byte type `char` in
Rust).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants