{"record":{"id":"0e965b88025b3466","repo":"fish-shell/fish-shell","slug":"eventfd","errorCode":null,"errorMessage":"eventfd","messagePattern":"eventfd","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/fd_monitor.rs","lineNumber":49,"sourceCode":"/// [`try_consume()`](FdEventSignaller::try_consume) may be used to consume the event.\n/// Importantly this is async signal safe. Of course it is `CLOEXEC` as well.\npub struct FdEventSignaller {\n    // Always the read end of the fd; maybe the write end as well.\n    fd: OwnedFd,\n    #[cfg(not(have_eventfd))]\n    write: OwnedFd,\n}\n\nimpl FdEventSignaller {\n    /// The default constructor will abort on failure (fd exhaustion).\n    /// This should only be used during startup.\n    pub fn new() -> Self {\n        cfg_if! {\n            if #[cfg(have_eventfd)] {\n                // Note we do not want to use EFD_SEMAPHORE because we are binary (not counting) semaphore.\n                let fd = unsafe { libc::eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK) };\n                if fd < 0 {\n                    perror(\"eventfd\");\n                    exit_without_destructors(1);\n                }\n                use crate::fds::heightenize_fd;\n                let Ok(fd) = heightenize_fd(unsafe { OwnedFd::from_raw_fd(fd) }, true) else {\n                    perror(\"eventfd\");\n                    exit_without_destructors(1);\n                };\n                Self {\n                    fd\n                }\n            } else {\n                // Implementation using pipes.\n                let Ok(pipes) = make_autoclose_pipes() else {\n                    exit_without_destructors(1);\n                };\n                make_fd_nonblocking(pipes.read.as_raw_fd()).unwrap();\n                make_fd_nonblocking(pipes.write.as_raw_fd()).unwrap();\n                Self {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/fish-shell/fish-shell/blob/edb719d76c8f76633f09dbbccedbda1823a7d9d5/src/fd_monitor.rs#L31-L67","documentation":"FdMonitor::new creates its wakeup pipe via libc::eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK) on platforms with eventfd support. If eventfd returns a negative fd (kernel too old, fd limit exhausted, or out of memory), fish prints perror(\"eventfd\") and calls exit_without_destructors(1), aborting the process immediately.","triggerScenarios":"Startup or first use of FdMonitor when the eventfd(2) syscall fails: RLIMIT_NOFILE exhausted (EMFILE), ENFILE/EINTR persisting, or running on a kernel/container without eventfd support despite the build flag have_eventfd being enabled.","commonSituations":"Containers/seccomp profiles blocking eventfd, hitting the file-descriptor limit after many open files/sockets, very old kernels or minimal embedded systems where CONFIG_EVENTFD is disabled.","solutions":["Raise the file descriptor limit: `ulimit -n 65536` or adjust RLIMIT_NOFILE / systemd LimitNOFILE","Check seccomp/container policy (Docker/Podman) allows the eventfd(2) syscall","Confirm the kernel supports eventfd (CONFIG_EVENTFD=y); otherwise rebuild fish for a non-eventfd configuration","Inspect `cat /proc/sys/fs/file-nr` for system-wide fd exhaustion"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# shell check before launching fish\nif [ \"$(cat /proc/sys/fs/file-nr | awk '{print $1}')\" -gt \"$(ulimit -n)\" -o \"$(ulimit -n)\" -lt 1024 ]; then\n  echo \"fd limit too low / nearly exhausted\" >&2\nfi","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Raise RLIMIT_NOFILE in shell profile or systemd unit (LimitNOFILE)","Allow eventfd(2) in container seccomp profiles","Monitor /proc/sys/fs/file-nr for system-wide fd exhaustion","Ensure kernel has CONFIG_EVENTFD enabled before deploying"],"tags":["linux","syscall","eventfd","file-descriptors"],"backgroundTag":"eventfd-creation-failed","analyzedSha":"edb719d76c8f76633f09dbbccedbda1823a7d9d5","analyzedAt":"2026-09-03T01:23:54.744Z","contentChangedAt":"2026-09-03T01:23:54.744Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}