WASI icon indicating copy to clipboard operation
WASI copied to clipboard

Map `Ctrl+C` to cancellation of the main function

Open badeend opened this issue 3 weeks ago • 6 comments

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 run task is the canonical way to do so.

WDYT?


Related: https://github.com/WebAssembly/WASI/issues/166

badeend avatar Dec 27 '25 12:12 badeend