mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-18 00:00:09 +02:00
49 lines
1.2 KiB
Markdown
49 lines
1.2 KiB
Markdown
# tokio-process
|
|
|
|
An implementation of process management for Tokio
|
|
|
|
[Documentation](https://docs.rs/tokio-process/0.2.4/tokio_process)
|
|
|
|
## Usage
|
|
|
|
First, add this to your `Cargo.toml`:
|
|
|
|
```toml
|
|
[dependencies]
|
|
tokio-process = "0.2"
|
|
```
|
|
|
|
Next you can use this in conjunction with the `tokio` and `futures` crates:
|
|
|
|
```rust,no_run
|
|
use std::process::Command;
|
|
|
|
use futures::Future;
|
|
use tokio_process::CommandExt;
|
|
|
|
fn main() {
|
|
// Use the standard library's `Command` type to build a process and
|
|
// then execute it via the `CommandExt` trait.
|
|
let child = Command::new("echo").arg("hello").arg("world").spawn_async();
|
|
|
|
// Make sure our child succeeded in spawning and process the result
|
|
let future = child
|
|
.expect("failed to spawn")
|
|
.map(|status| println!("exit status: {}", status))
|
|
.map_err(|e| panic!("failed to wait for exit: {}", e));
|
|
|
|
// Send the future to the tokio runtime for execution
|
|
tokio::run(future)
|
|
}
|
|
```
|
|
|
|
## License
|
|
|
|
This project is licensed under the [MIT license](./LICENSE).
|
|
|
|
### Contribution
|
|
|
|
Unless you explicitly state otherwise, any contribution intentionally submitted
|
|
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
|
|
terms or conditions.
|