WASI
WASI copied to clipboard
Map `Ctrl+C` to cancellation of the main function
Currently, WASI does not describe any way for a CLI guest to receive the Ctrl+C signal (SIGINT on Unix). This signal is commonly used to request graceful shutdown, giving the application some time to e.g.:
- clean up resources,
- flush buffers to disk,
- stop listening for new network requests, while letting the existing ones run to completion,
- etc..
The component model has built-in support for async cancellation, and I think that in the CLI world Ctrl+C maps neatly to cancellation of the main (run) function.
I propose we update the documentation of the run function to say something along the lines of:
If a host wishes to propagate Ctrl+C into the guest, then cancellation of the
runtask is the canonical way to do so.
WDYT?
Related: https://github.com/WebAssembly/WASI/issues/166