GitHunt
SU

sunshowers/rustconf-2023-signals

Supplementary materials for RustConf 2023 talk on signal handling

Beyond Ctrl-C: The dark corners of Unix signal handling

These are supplementary materials for Rain's RustConf 2023 talk on signal handling with Rust.

The presentation

  • My website ๐ŸŒ
  • Mastodon ๐Ÿ˜: @rain@hachyderm.io
  • Bluesky: @sunshowers.io --- I'm less active there but happy to answer questions if you tag me there
  • Email โœ‰๏ธ: at rustconf23 at sunshowers.io.
  • I do not have an active "X"/Twitter account.
  • I mentioned towards the beginning of the talk that the terminal sends the SIGINT signal to the process. In reality it's actually a component called the tty driver, which is implemented within the kernel, which does so. For more, see this excellent documentation on the WezTerm site.

  • Most of the content of the talk comes from me learning about how to use signals with
    cargo-nextest. Nextest is a next-generation test runner for Rust with much
    faster test runs and many other features. Try it out and star it on GitHub!

  • I'm the maintainer of a number of Rust crates. If the
    standard library's Path::to_str and Path::display have ever annoyed you, check out
    camino (GitHub) for UTF-8 paths. (The download manager demo uses camino.)

  • Doug McIlroy's 2015 mailing list post about signals.

    Signal() was there first and foremost to support SIGKILL; it
    did not purport to provide a sound basis for asynchronous IPC.
    The complexity of sigaction() is evidence that asynchrony remains
    untamed 40 years on.

Contents

download-manager

The download-manager directory contains a simple download manager, used as an example in the
presentation. Run it from the root directory with:

cargo run -p download-manager -- run dl-manifest.toml

This will kick off downloads for two Linux ISOs (see dl-manifest.toml) into the out/
directory.

Try pressing Ctrl-C while the downloads are happening! You should see the signal handler kick in,
and log entries saying that the downloads have been marked as interrupted.

There are several exercises included in the source code -- search for TODO/exercise and try them
out! Each exercise has a difficulty level next to it. Feel free to create forks with solutions, but
please do not send pull requests with solutions.

Contributing

Pull requests fixing typos or clarifying content are welcome. Please do not send PRs containing demo
solutions.

License

The code in this repository was originally written by me (Rain). Copyright has been waived to the
greatest extent possible, as specified by
CC0-1.0. (However, note that if
you distribute a version of the download-manager binary, the licenses of the upstream crates used
will prevail.)

The slides are under CC BY 4.0.

Languages

Rust100.0%

Contributors

Creative Commons Zero v1.0 Universal
Created September 5, 2023
Updated December 28, 2025