merge: combine 0a358aa0 (diag + libc::pipe2 fix) with 104da7de (init FILETABLE fix) into canonical submodule/base

Both branches independently fixed the FILETABLE desync bug. This merge creates a single canonical history that preserves the diagnostic commits from 0a358aa0 and the eexist-focused fix from 104da7de.

After this merge, the per-fork submodule/<name> branch (this is the AGENTS.md-mandated canonical ref) is a child of both, so origin can fast-forward to it.

(NO AI attribution in commit message body, per project policy)
This commit is contained in:
Red Bear OS
2026-07-14 12:19:46 +09:00
+9 -2
View File
@@ -38,8 +38,15 @@ pub enum ServiceType {
fn create_pipe() -> io::Result<(File, OwnedFd)> {
let mut fds = [0i32; 2];
let res = unsafe { libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC) };
if res != 0 {
// Use libc::pipe2() which goes through relibc's FILETABLE-managed path
// (FdGuard::open → SYS_OPENAT_INTO), keeping the userspace file table in
// sync with the kernel's file table. Using raw syscall::openat()
// (SYS_OPENAT) here would bypass the FILETABLE and create phantom fds
// that later cause EEXIST collisions when relibc's own pipe2() (called
// during Command::spawn fork+exec) tries to insert at a position the
// FILETABLE incorrectly thinks is free.
let ret = unsafe { libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC) };
if ret != 0 {
return Err(io::Error::last_os_error());
}
let rd = unsafe { File::from_raw_fd(fds[0]) };