From 8adfb542eb035f3c567fda2c1bfc9aa66eedc454 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds stdin, stderr, and stdout options to WASI, which allow the stdio streams to be configured. PR-URL: https://github.com/nodejs/node/pull/33544 Reviewed-By: Anna Henningsen Reviewed-By: David Carlier Reviewed-By: Juan José Arboleda Reviewed-By: Zeyu Yang Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- 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 23c2182fff8ffd..e9c39d868aa90f 100644 --- a/doc/api/wasi.md +++ b/doc/api/wasi.md @@ -62,6 +62,12 @@ added: v12.16.0 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)`