wasm3 / wasm3-rs

Rust wrapper for Wasm3, the fastest WebAssembly interpreter
MIT License
155 stars 43 forks source link

Is there a way to override STDOUT for WASI? #6

Closed technosophos closed 3 years ago

technosophos commented 4 years ago

It would be nice to be able to specify a location to write to STDOUT so that the calling process can capture STDOUT. Is that something that is possible?

Veykril commented 4 years ago

I don't think there is such a feature in wasm3 (yet)? I'd say ask the same question on the wasm3 repo or discord.

technosophos commented 4 years ago

Okay. Thank you. I will start with wasm3 itself and work my way from there. Thanks for providing the Rust bindings. I have been experimenting with them, and they are very easy to use.

Veykril commented 4 years ago

I have been experimenting with them, and they are very easy to use.

That's nice to hear. I'm still having a bit of trouble figuring out the exact API I'd like to have(#4).

bacongobbler commented 4 years ago

Hey there. I'm picking up the same work @technosophos was working on a few months ago.

For context, we are using this project over at https://github.com/deislabs/krustlet-wasm3 to execute WASI workloads in Kubernetes with the wasm3 runtime.

I did some digging and have not found a solution available under wasm3. It is not currently possible to pipe a function's output to a file like we can with wasmtime. @Veykril's suggestion is correct here.

I'll keep looking upstream for ideas.

Veykril commented 4 years ago

I've gone and dropped a question regarding this feature in the wasm3 discord.

Veykril commented 4 years ago

Blocked on https://github.com/wasm3/wasm3/issues/147

vshymanskyy commented 3 years ago

Looks like wasm3-rs is using a simplistic version of WASI implementation: https://github.com/Veykril/wasm3-rs/blob/f064cbb09672a24170e5c0e33d05169d767468ca/wasm3-sys/build.rs#L158 It would be really cool if we could switch to uvwasi (which is default, more complete and maintained).

As for redirecting stdout/stderr, it's absolutely doable with this approach: https://github.com/wasm3/wasm3/issues/147#issuecomment-636530465 Question is, do you need to redirect the output to an arbitrary file descriptor, or to register some kind of callbacks/hooks to intercept it. Also, what about stdin?

vshymanskyy commented 3 years ago

Closing due to lack of interest