Skip to content
Snippets Groups Projects
Commit 44ca6d09 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Don't forget to close executable file

parent 8649d849
No related branches found
No related tags found
No related merge requests found
......@@ -191,13 +191,16 @@ pub fn execve<S: AsRef<str>>(prog: &str, args: &[S], clear_env: bool) -> io::Err
};
if let Some(prog) = prog {
let fd = match syscall::open(prog.as_os_str().as_bytes(), syscall::O_RDONLY) {
let fd = match syscall::open(prog.as_os_str().as_bytes(), syscall::O_RDONLY | syscall::O_CLOEXEC) {
Ok(fd) => fd,
Err(err) => return io::Error::from_raw_os_error(err.errno)
};
// If we found the program. Run it!
let error = syscall::fexec(fd, &cvt_args, &env_args);
let _ = syscall::close(fd);
io::Error::from_raw_os_error(error.err().unwrap().errno)
} else {
// The binary was not found.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment