Go to file
Taiki Endo fbc300608c Fix clippy::single_match warning in test
```
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
  --> tests/std.rs:26:5
   |
26 | /     match Command::new("if-this-is-a-binary-then-the-world-has-ended").spawn() {
27 | |         Ok(..) => panic!(),
28 | |         Err(..) => {}
29 | |     }
   | |_____^ help: try this: `if let Ok(..) = Command::new("if-this-is-a-binary-then-the-world-has-ended").spawn() { panic!() }`
   |
   = note: `#[warn(clippy::single_match)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
```
2022-07-17 21:31:38 +09:00
.github/workflows Apply clippy to all targets 2022-07-17 21:21:19 +09:00
src Impl From<std::process::Command> for Command 2022-01-27 20:46:09 +01:00
tests Fix clippy::single_match warning in test 2022-07-17 21:31:38 +09:00
.clippy.toml Clean up CI config 2022-01-08 22:03:15 +09:00
.gitignore
CHANGELOG.md Bump to v1.4.0 2022-05-01 13:57:48 +09:00
Cargo.toml Bump to v1.4.0 2022-05-01 13:57:48 +09:00
LICENSE-APACHE
LICENSE-MIT
README.md Update license badge to match Cargo.toml 2021-02-14 13:38:37 +09:00

README.md

async-process

Build License Cargo Documentation

Async interface for working with processes.

This crate is an async version of std::process.

Implementation

A background thread named "async-process" is lazily created on first use, which waits for spawned child processes to exit and then calls the wait() syscall to clean up the "zombie" processes. This is unlike the process API in the standard library, where dropping a running Child leaks its resources.

This crate uses async-io for async I/O on Unix-like systems and blocking for async I/O on Windows.

Examples

Spawn a process and collect its output:

use async_process::Command;

let out = Command::new("echo").arg("hello").arg("world").output().await?;
assert_eq!(out.stdout, b"hello world\n");

Read the output line-by-line as it gets produced:

use async_process::{Command, Stdio};
use futures_lite::{io::BufReader, prelude::*};

let mut child = Command::new("find")
    .arg(".")
    .stdout(Stdio::piped())
    .spawn()?;

let mut lines = BufReader::new(child.stdout.take().unwrap()).lines();

while let Some(line) = lines.next().await {
    println!("{}", line?);
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.