https://github.com/zitsen/tokio-process-terminate
Terminate or CTRL+C for tokio::process::Child
https://github.com/zitsen/tokio-process-terminate
Last synced: 9 months ago
JSON representation
Terminate or CTRL+C for tokio::process::Child
- Host: GitHub
- URL: https://github.com/zitsen/tokio-process-terminate
- Owner: zitsen
- Created: 2023-11-08T05:59:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-03T13:26:42.000Z (over 2 years ago)
- Last Synced: 2025-09-28T00:32:04.639Z (9 months ago)
- Language: Rust
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# tokio-process-terminate
Extensions to `tokio::process::Child` to terminate processes.
```rust
use tokio::process::Command;
use tokio_process_terminate::TerminateExt;
#[tokio::main]
async fn main() {
let mut command = Command::new("sleep")
.arg("10")
.spawn()
.unwrap();
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
let exit = command.terminate_wait().await.unwrap();
dbg!(exit);
let code = exit.code();
// On Unix, code should be `None` if the process was terminated by a signal.
assert!(code.is_none());
}
```