Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement cross platform signal handling with
tokio
(#183)
* ctrlc: also handle `sigterm` and `sighup` via `termination` feature This commit enables the `termination` feature in `ctrlc` so that `sigterm` and `sighup` are also handled on UNIX systems. This in turn improves Docker compatibility since containers now listen to the `SIGTERM` signal it sends to containers when trying to stop the container via `Ctrl-C` whilst attached. * Replace `ctrlc` signal handling with `tokio` This removes the `ctrlc` crate from the project, replacing (and upgrading) its functionality to also handle `sigterm` and `sighup`. Sigterm handling is working on UNIX with this commit, I haven't tested Windows compatibility with `Ctrl-C` nor have I tested `sighup` or `sigint`. Of course, compiles and runs on UNIX. Haven't tested Windows. * fix: remove unused import; collapse if statement * main: fix per-os signal handling Will only compile Windows-specific/Unix-specific code when on their respective environments. Handles signals in a separate tokio thread so it doesn't suspend the main thread. Tested to work on UNIX (macOS) but not tested on Windows. * main: cargo fmt * main: fix setup_sighandler fn signature on windows * main: attempt 2 at fixing windows sighandler * main: enable ctrlc for all non-unix systems Previously, ctrlc usage in tokio was only enabled on Windows systems (since UNIX systems have their own signal handling in Pumpkin). Instead of limiting ctrlc to just Windows, we can make it run on any non-UNIX system since it should be platform independent anyhow.
- Loading branch information