Dont let Nu childs become zombies.

This commit is contained in:
Andrés N. Robalino 2019-08-06 00:34:06 -05:00
parent c231dd32cd
commit b38d54e033

View File

@ -21,7 +21,7 @@ macro_rules! nu {
$cwd, $commands $cwd, $commands
); );
let process = match Command::new(helpers::executable_path()) let mut process = match Command::new(helpers::executable_path())
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.spawn() .spawn()
@ -30,22 +30,18 @@ macro_rules! nu {
Err(why) => panic!("Can't run test {}", why.description()), Err(why) => panic!("Can't run test {}", why.description()),
}; };
match process.stdin.unwrap().write_all(commands.as_bytes()) { let stdin = process.stdin.as_mut().expect("couldn't open stdin");
Err(why) => panic!("couldn't write to wc stdin: {}", why.description()), stdin
Ok(_) => {} .write_all(commands.as_bytes())
} .expect("couldn't write to stdin");
let mut _s = String::new(); let output = process
.wait_with_output()
.expect("couldn't read from stdout");
match process.stdout.unwrap().read_to_string(&mut _s) { let $out = String::from_utf8_lossy(&output.stdout);
Err(why) => panic!("couldn't read stdout: {}", why.description()), let $out = $out.replace("\r\n", "");
Ok(_) => { let $out = $out.replace("\n", "");
let _s = _s.replace("\r\n", "\n");
}
}
let _s = _s.replace("\r\n", "");
let $out = _s.replace("\n", "");
}; };
} }
@ -189,6 +185,10 @@ pub fn file_exists_at(full_path: &str) -> bool {
PathBuf::from(full_path).exists() PathBuf::from(full_path).exists()
} }
pub fn dir_exists_at(full_path: &str) -> bool {
PathBuf::from(full_path).exists()
}
pub fn delete_directory_at(full_path: &str) { pub fn delete_directory_at(full_path: &str) {
std::fs::remove_dir_all(PathBuf::from(full_path)).expect("can not remove directory"); std::fs::remove_dir_all(PathBuf::from(full_path)).expect("can not remove directory");
} }