fix(pipe2): use FILETABLE-aware open/dup to keep kernel/userspace fd tables in sync

This commit is contained in:
Red Bear OS
2026-07-14 08:01:33 +09:00
parent 10023d5715
commit d2648af84a
+5 -9
View File
@@ -20,18 +20,14 @@ pub fn pipe2(flags: usize) -> syscall::error::Result<[c_int; 2]> {
let read_flags = flags | O_RDONLY;
let write_flags = flags | O_WRONLY;
let ns_fd = redox_rt::current_namespace_fd()?;
let read_fd = syscall::openat(ns_fd, "/scheme/pipe", read_flags, 0)?;
redox_rt::sys::register_external_fd(read_fd)?;
let write_fd = syscall::dup(read_fd, b"write")?;
redox_rt::sys::register_external_fd(write_fd)?;
// Use the FILETABLE-aware path so kernel and userspace fd tables stay in sync.
let read_fd = redox_rt::sys::open("/scheme/pipe", read_flags)?;
let write_fd = redox_rt::sys::dup(read_fd, b"write")?;
if flags & O_CLOEXEC != 0 {
let _ = syscall::fcntl(write_fd, F_SETFD, O_CLOEXEC);
let _ = redox_rt::sys::fcntl(write_fd, F_SETFD, O_CLOEXEC);
}
let _ = syscall::fcntl(write_fd, F_SETFL, write_flags);
let _ = redox_rt::sys::fcntl(write_fd, F_SETFL, write_flags);
Ok([read_fd as c_int, write_fd as c_int])
}