From af14c1f77645e8d2fed24b0d364c2f2aff3505d8 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 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)`