1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 #![feature(process_try_wait)]
16 use std::process::Command;
18 use std::time::Duration;
21 let args = env::args().collect::<Vec<_>>();
24 "sleep" => thread::sleep(Duration::new(1_000, 0)),
30 let mut me = Command::new(env::current_exe().unwrap())
34 let maybe_status = me.try_wait().unwrap();
35 assert!(maybe_status.is_none());
36 let maybe_status = me.try_wait().unwrap();
37 assert!(maybe_status.is_none());
42 let status = me.try_wait().unwrap().unwrap();
43 assert!(!status.success());
44 let status = me.try_wait().unwrap().unwrap();
45 assert!(!status.success());
47 let mut me = Command::new(env::current_exe().unwrap())
48 .arg("return-quickly")
54 assert!(res.success());
58 thread::sleep(Duration::from_millis(1));
60 Err(e) => panic!("error in try_wait: {}", e),
64 let status = me.try_wait().unwrap().unwrap();
65 assert!(status.success());