aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pty.rs
blob: 3f3819309801cbd9ef05401bfab440b06f93c96a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use futures::future::{Future, IntoFuture};
use tokio_pty_process::CommandExt;

fn main() {
    tokio::run(futures::future::lazy(move || {
        let master = tokio_pty_process::AsyncPtyMaster::open().unwrap();
        let args: Vec<&str> = vec![];
        let child = std::process::Command::new("false")
            .args(&args)
            .spawn_pty_async(&master)
            .unwrap();
        tokio::spawn(
            child
                .map(|status| {
                    eprintln!("got status {}", status);
                })
                .map_err(|_| ()),
        )
        .into_future()
        .wait()
        .unwrap();
        futures::future::ok(())
    }));
}