From e3d50e5633fe66821436743a9798a85fc88a5dc2 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 26 Mar 2020 00:22:13 -0400 Subject: [PATCH] wasi: allow WASI stdio to be configured This commit adds stdin, stderr, and stdout options to WASI, which allow the stdio streams to be configured. --- doc/api/wasi.md | 6 ++++ lib/wasi.js | 9 +++++- src/node_wasi.cc | 15 +++++++--- test/wasi/test-wasi-options-validation.js | 12 ++++++++ test/wasi/test-wasi-stdio.js | 34 +++++++++++++++++++++++ 5 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 test/wasi/test-wasi-stdio.js diff --git a/doc/api/wasi.md b/doc/api/wasi.md index ebaf15525d03f0..3f9c6c7f51bcb9 100644 --- a/doc/api/wasi.md +++ b/doc/api/wasi.md @@ -66,6 +66,12 @@ added: process via the `__wasi_proc_exit()` function. Setting this option to `true` causes `wasi.start()` to return the exit code rather than terminate the process. **Default:** `false`. + * `stdin` {integer} The file descriptor used as standard input in the + WebAssembly application. **Default:** `0`. + * `stdout` {integer} The file descriptor used as standard output in the + WebAssembly application. **Default:** `1`. + * `stderr` {integer} The file descriptor used as standard error in the + WebAssembly application. **Default:** `2`. ### `wasi.start(instance)`