Skip to content

Commit 2906964

Browse files
committed
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.
1 parent c6b0b33 commit 2906964

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

legacy/application-abi.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ Regardless of the kind, all modules accessing WASI APIs also export a table
5151
with the name `__indirect_function_table`. Function pointers in WASI API calls
5252
are relative to this table's index space.
5353

54+
When `_start` or `_initialize` is called, environments shall provide file
55+
descriptors with indices 0, 1, and 2 representing file-like resources for
56+
standard input, standard output, and standard error. Environments may provide
57+
additional "preopen" file descriptors that can be inspected with
58+
`fd_prestat_get` and `fd_prestat_dir_name`. These resources may be closed at
59+
any time.
60+
5461
Environments shall not access exports named `__heap_base` or `__data_end`.
5562
Toolchains are encouraged to avoid providing these exports.
5663

0 commit comments

Comments
 (0)