WebAssembly / WebAssembly/WASI

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

Open
#858 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-cli
Dominant language
Rust
Stars
5.8k
Forks
333
Avg merge
2d 13h
Merged PRs (30d)
3

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked proposals/cli/wit-0.3.0-draft/run.wit file and review the run function documentation in light of the Ctrl+C and async-cancellation behavior described here. Check related issue #166 for context, then update the run documentation if the canonical cancellation guidance is accepted; done means the behavior is explicitly documented for hosts and guests.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
cli, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.