fix popen, improve tests

This commit is contained in:
Ron Williams
2024-12-26 17:13:47 -08:00
parent 8deec75e45
commit 9df3708a1a
5 changed files with 25 additions and 14 deletions
+8 -2
View File
@@ -917,9 +917,15 @@ pub unsafe extern "C" fn popen(command: *const c_char, mode: *const c_char) -> *
//TODO: dup errors are ignored, should they be?
{
if write {
unistd::dup2(0, pipes[0]);
match unistd::dup2(pipes[0], 0) {
0 => {}
e => stdlib::exit(127),
}
} else {
unistd::dup2(1, pipes[1]);
match unistd::dup2(pipes[1], 1) {
1 => {}
e => stdlib::exit(127),
}
}
unistd::close(pipes[0]);