Skip to content

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

Description

@amysyk-viax-io

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions