Don't forget to close executable file
This commit is contained in:
parent
b400005861
commit
8c277d843c
1 changed files with 2 additions and 1 deletions
|
@ -318,7 +318,7 @@ impl Command {
|
||||||
};
|
};
|
||||||
|
|
||||||
let fd = if let Some(program) = program {
|
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 {
|
} else {
|
||||||
return io::Error::from_raw_os_error(syscall::ENOENT);
|
return io::Error::from_raw_os_error(syscall::ENOENT);
|
||||||
};
|
};
|
||||||
|
@ -341,6 +341,7 @@ impl Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = syscall::fexec(fd, &args, &vars) {
|
if let Err(err) = syscall::fexec(fd, &args, &vars) {
|
||||||
|
let _ = syscall::close(fd);
|
||||||
io::Error::from_raw_os_error(err.errno as i32)
|
io::Error::from_raw_os_error(err.errno as i32)
|
||||||
} else {
|
} else {
|
||||||
panic!("return from exec without err");
|
panic!("return from exec without err");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue