Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interesting bits: - End-of-stream (EOS, aka EOF) is indicated by returning the `$success_eos` errno value. - This differs from POSIX, where EOS is indicated by having `read` return 0, which is ambiguous in several cases. Of course, WASI libc will continue to provide POSIX semantics to C users. - This is a success condition being indicated with a non-zero errno value, which does not have precedent in POSIX. - `$fdstat`'s `$filetype` field is removed. The `$filetype` is still available through the `$filestat` type, though note that it's now protected by a rights flag. The goal is to start abstracting away more of the differences between files and sockets. - The `$peek` and `$waitall` flags are now available on `$read`, and can be used on files. This differs from POSIX. - POSIX says that `recv` and `send` fail if the stream is not a socket, but with `recv`/`send` merged into `read`/`write`, this restriction will no longer be automatically enforced. It could be manually enforced in WASI libc if needed, but in most cases, it's probably not important. - There is a new `$fd_line_oriented_terminal` right, to support `isatty`. I also anticipate expanding on this right in my upcoming terminal I/O proposal. - `$read`'s `$nread` result can be larger than the provided buffer to indicate a truncate message on a message-oriented socket (see also `$recv_data_truncated` in the current API, or `MSG_TRUNC` in POSIX `recv`. This avoids the need for a separate output value, but is it too surprising? Out of scope for this proposal (but maybe in scope in the future!): - Streams vs datagrams - Having these merged is tricky, but this isn't new here; both `read` and `recv` already support both streams and datagrams. - Streams vs arrays - POSIX unifies the concept of a file as an array of bytes with the concept of file as a stream of data, which creates some tricky situations, but this also isn't new here. - Out-of-band messages and connectionless sockets aren't in WASI, and this proposal doesn't change that. This implements WebAssembly#4.
- Loading branch information