{"record":{"id":"02a2a92c0514f227","repo":"kovidgoyal/kitty","slug":"failed-to-write-to-s-wakeup-fd-with-error-s","errorCode":null,"errorMessage":"Failed to write to %s wakeup fd with error: %s","messagePattern":"Failed to write to (.+?) wakeup fd with error: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kitty/loop-utils.c","lineNumber":132,"sourceCode":"    safe_close(ld->wakeup_read_fd, __FILE__, __LINE__);\n#endif\n    ld->wakeup_read_fd = -1;\n    remove_signal_handlers(ld);\n}\n\n\nvoid\nwakeup_loop(LoopData *ld, bool in_signal_handler, const char *loop_name) {\n    while (true) {\n#ifdef HAS_EVENT_FD\n        static const int64_t value = 1;\n        ssize_t ret = write(ld->wakeup_read_fd, &value, sizeof value);\n#else\n        ssize_t ret = write(ld->wakeup_fds[1], \"w\", 1);\n#endif\n        if (ret < 0) {\n            if (errno == EINTR) continue;\n            if (!in_signal_handler) log_error(\"Failed to write to %s wakeup fd with error: %s\", loop_name, strerror(errno));\n        }\n        break;\n    }\n}\n\n\nvoid\nread_signals(int fd, handle_signal_func callback, void *data) {\n#ifdef HAS_SIGNAL_FD\n    static struct signalfd_siginfo fdsi[32];\n    siginfo_t si;\n    while (true) {\n        ssize_t s = read(fd, &fdsi, sizeof(fdsi));\n        if (s < 0) {\n            if (errno == EINTR) continue;\n            if (errno == EAGAIN) break;\n            log_error(\"Call to read() from read_signals() failed with error: %s\", strerror(errno));\n            break;","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/loop-utils.c#L114-L150","documentation":"Writing a wakeup byte to the loop's wakeup pipe/eventfd failed; this fd is how other threads and signal handlers rouse the select/epoll io loop, so a lost wakeup may delay processing until the next timeout. Suppressed when called from a signal handler.","triggerScenarios":"wakeup_io_loop / wakeup_talk_loop / wakeup_write_loop writing to the wakeup fd when it is closed (EBADF), full (EAGAIN on a non-blocking pipe), or under fd exhaustion (EMFILE).","commonSituations":"Shutdown races where the io loop closes while another thread signals it; fd leaks from other software.","solutions":["Ignore if it appears only during shutdown - benign","Upgrade kitty; wakeup race handling improves over time","Check for fd leaks (EMFILE) by comparing with ulimit -n","Report upstream with a reproducer if it recurs during normal use"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat as benign during shutdown","Report recurring cases with fd-usage info"],"tags":["kitty","event-loop","pipe","wakeup"],"backgroundTag":"pipe-write-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}