From 2906964caa9e602ac59ca43c28b07d09b1095056 Mon Sep 17 00:00:00 2001 From: Dan Gohman <dev@sunfishcode.online> Date: Fri, 24 Feb 2023 14:09:12 -0800 Subject: [PATCH 1/2] Add documentation about starting file descriptors in Preview1. Add documentation mentioning stdin, stdout, and stderr file descriptors, and also preopen file descriptors, and mention that preopen file descriptors can be closed. Allowing preopen file descriptors to be closed is a change from how Wasmtime historically worked, but I think it's more clear now that it's ok to let preopens be closed. We'll change Wasmtime accordingly. This addresses WebAssembly/wasi-testsuite#50. --- legacy/application-abi.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/legacy/application-abi.md b/legacy/application-abi.md index a87f9d27..8c8893a7 100644 --- a/legacy/application-abi.md +++ b/legacy/application-abi.md @@ -51,6 +51,13 @@ Regardless of the kind, all modules accessing WASI APIs also export a table with the name `__indirect_function_table`. Function pointers in WASI API calls are relative to this table's index space. +When `_start` or `_initialize` is called, environments shall provide file +descriptors with indices 0, 1, and 2 representing file-like resources for +standard input, standard output, and standard error. Environments may provide +additional "preopen" file descriptors that can be inspected with +`fd_prestat_get` and `fd_prestat_dir_name`. These resources may be closed at +any time. + Environments shall not access exports named `__heap_base` or `__data_end`. Toolchains are encouraged to avoid providing these exports. From de5cae285c378121e8152ac930149155c8ab0961 Mon Sep 17 00:00:00 2001 From: Dan Gohman <dev@sunfishcode.online> Date: Tue, 28 Feb 2023 07:05:11 -0800 Subject: [PATCH 2/2] Say "stream" instead of "file-like". --- legacy/application-abi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/legacy/application-abi.md b/legacy/application-abi.md index 8c8893a7..39373da6 100644 --- a/legacy/application-abi.md +++ b/legacy/application-abi.md @@ -52,7 +52,7 @@ with the name `__indirect_function_table`. Function pointers in WASI API calls are relative to this table's index space. When `_start` or `_initialize` is called, environments shall provide file -descriptors with indices 0, 1, and 2 representing file-like resources for +descriptors with indices 0, 1, and 2 representing stream resources for standard input, standard output, and standard error. Environments may provide additional "preopen" file descriptors that can be inspected with `fd_prestat_get` and `fd_prestat_dir_name`. These resources may be closed at