use inherit to print output.

This commit is contained in:
licsber 2024-09-19 17:22:59 +08:00
parent 140e9ebe1c
commit 09b4d36a72

21
src/retry.rs Normal file
View File

@ -0,0 +1,21 @@
use std::process::{Command, Stdio};
use std::thread;
use std::time::Duration;
pub fn retry(cmd: &str, cmd_args: &[String]) {
loop {
let mut child = Command::new(cmd)
.args(cmd_args)
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.spawn()
.expect("Failed to spawn command.");
if child.wait().unwrap().success() {
break;
}
println!("Error, wait 1s for retry.");
thread::sleep(Duration::from_secs(1));
}
}