Skip to content

Commit

Permalink
Don't forget to close executable file
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 authored and jD91mZM2 committed Oct 18, 2018
1 parent b400005 commit 8c277d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libstd/sys/redox/process.rs
Expand Up @@ -318,7 +318,7 @@ impl Command {
};

let fd = if let Some(program) = program {
t!(cvt(syscall::open(program.as_os_str().as_bytes(), syscall::O_RDONLY)))
t!(cvt(syscall::open(program.as_os_str().as_bytes(), syscall::O_RDONLY | syscall::O_CLOEXEC)))
} else {
return io::Error::from_raw_os_error(syscall::ENOENT);
};
Expand All @@ -341,6 +341,7 @@ impl Command {
}

if let Err(err) = syscall::fexec(fd, &args, &vars) {
let _ = syscall::close(fd);
io::Error::from_raw_os_error(err.errno as i32)
} else {
panic!("return from exec without err");
Expand Down

0 comments on commit 8c277d8

Please sign in to comment.