-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for
Process::parent
update
- Loading branch information
1 parent
1cc03e7
commit 24aaabc
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
// Does nothing and just exits after waiting for 30 seconds. | ||
|
||
use std::process::{Child, Command}; | ||
|
||
fn maybe_start_child(last: String, args: &[String]) -> Option<Child> { | ||
if last == "1" { | ||
let mut cmd = Command::new(&args[0]); | ||
for arg in &args[1..] { | ||
cmd.arg(arg); | ||
} | ||
Some(cmd.spawn().expect("failed to run command")) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
fn main() { | ||
std::thread::sleep(std::time::Duration::from_secs(30)); | ||
let mut args: Vec<String> = std::env::args().collect(); | ||
let child = args.pop().and_then(|last| maybe_start_child(last, &args)); | ||
if child.is_some() { | ||
std::thread::sleep(std::time::Duration::from_secs(3)); | ||
} else { | ||
std::thread::sleep(std::time::Duration::from_secs(30)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters