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)]
17 use std::process::Command;
19 use std::time::Duration;
22 let args = env::args().collect::<Vec<_>>();
25 "sleep" => thread::sleep(Duration::new(1_000, 0)),
31 let mut me = Command::new(env::current_exe().unwrap())
35 let err = me.try_wait().unwrap_err();
36 assert_eq!(err.kind(), io::ErrorKind::WouldBlock);
37 let err = me.try_wait().unwrap_err();
38 assert_eq!(err.kind(), io::ErrorKind::WouldBlock);
43 let status = me.try_wait().unwrap();
44 assert!(!status.success());
45 let status = me.try_wait().unwrap();
46 assert!(!status.success());
48 let mut me = Command::new(env::current_exe().unwrap())
49 .arg("return-quickly")
55 assert!(res.success());
58 Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
59 thread::sleep(Duration::from_millis(1));
61 Err(e) => panic!("error in try_wait: {}", e),
65 let status = me.try_wait().unwrap();
66 assert!(status.success());