Skip to content

Commit 8c277d8

Browse files
jackpot51jD91mZM2
authored andcommitted
Don't forget to close executable file
1 parent b400005 commit 8c277d8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libstd/sys/redox/process.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl Command {
318318
};
319319

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

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

0 commit comments

Comments
 (0)