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

Wasi context stdin truncate file if exist, with no ability writing to it #54

Open
amysyk-viax-io opened this issue Nov 1, 2023 · 0 comments

Comments

@amysyk-viax-io
Copy link

Is there a way to pass data into stdin via wasi context?

When file already exist it will be truncated during wasi context creation

final var stdinPath = Paths.get("./wasm/io/stdin.txt");

Files.writeString(stdinPath, "{\"name\": \"John\"}");

final var wasi = new WasiCtxBuilder()
        .stdin(stdinPath)
        .build();

Another case, when trying to write data after context creation it is ignored

final var stdinPath = Paths.get("./wasm/io/stdin.txt");
final var wasi = new WasiCtxBuilder()
        .stdin(stdinPath)
        .build();

Files.writeString(stdinPath, "{\"name\": \"John\"}");

You can find full working example here: https://github.com/amysyk-viax-io/wasmtime-java-stdin-stdout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant