A while ago we added cli exit-with-code to the wasi-cli world, but it is still listed as "unstable" in https://github.com/WebAssembly/wasi-cli/blob/07e4b66066ee7c183b10e8ee696e5aa571e9fbef/wit/exit.wit#L15 so (I presume) we can't really use in e. g. wasi-libc yet. I am wondering what would the process be where the end result is it being usable from libc.
I think the steps would look more-or-less like:
The next big question is when to update wasi-libc. Unfortunately there's not a great answer there just yet. There's no preexisting policy about which version of the WITs are used to generate bindings in wasi-libc (it's only just now recently getting support for wasip2 natively). Additionally with Wasmtime's p1-to-p2 adapter there's no formal policy yet about what versions of WASI to support.
Basically it's required to get this to a stable API to use, but after that it's not 100% clear when default tooling can use this. If you're interested in pushing this forward I'd recommend starting with a presentation to the WASI SG and then getting it out in Wasmtime, and then after that we can see where we're at and what, if any, policies we need
Oh, thank you for such a quick and comprehensive reply :). I'll start working though the steps...
Regarding which WITs to use for wasi-libc: this is yet another example of where optional imports would be super useful. wasi-libc could optionally import exit-with-code and fall back to the old exit if needed.
agreed yeah, although the irony with optional imports is that they're mostly only useful if they were implemented a long time ago, if we were to implement optional imports today it'd still take a long time to percolate to all the runtimes and be usable for wasi-libc (same usability issues as using a newer WASI API on first-time-use)
All the more reason to do it ASAP.
easier said than done :)
On a semi-related note, inspired by this, we had some discussion today about this and I wrote down a plan:
Last updated: Dec 06 2025 at 06:05 UTC