bootstrap: Open things with O_CLOEXEC where possible

This commit is contained in:
bjorn3
2025-12-08 20:38:30 +01:00
parent 888b51a4eb
commit 3bdcd7b04d
+4 -3
View File
@@ -40,7 +40,8 @@ pub fn main() -> ! {
let mut env_bytes = [0_u8; 4096];
let envs = {
let fd = FdGuard::open("/scheme/sys/env", O_RDONLY).expect("bootstrap: failed to open env");
let fd = FdGuard::open("/scheme/sys/env", O_RDONLY | O_CLOEXEC)
.expect("bootstrap: failed to open env");
let bytes_read = fd
.read(&mut env_bytes)
.expect("bootstrap: failed to read env");
@@ -102,11 +103,11 @@ pub fn main() -> ! {
let path = "/scheme/initfs/bin/init";
let image_file = FdGuard::open(path, O_RDONLY)
let image_file = FdGuard::open(path, O_RDONLY | O_CLOEXEC)
.expect("failed to open init")
.to_upper()
.unwrap();
let memory = FdGuard::open("/scheme/memory", 0)
let memory = FdGuard::open("/scheme/memory", O_CLOEXEC)
.expect("failed to open memory")
.to_upper()
.unwrap();