From c16e7efa135e6516cd7321783a81370ee5cbe9cf Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 5 Jul 2026 10:06:55 +0200 Subject: [PATCH] fix(niri): close the IPC socket fd once (ScopedFd owns it), not twice IPC::send() wrapped the socket fd in a util::ScopedFd, which closes the fd in its destructor. The input stream was created with close_fd=true, so the stream also closed the same fd, resulting in a double-close. In multithreaded Waybar another thread can open a new fd with the same number between the two close() calls, which the second close() then wrongly closes. Pass close_fd=false so ScopedFd is the sole owner and the fd is closed exactly once. The streams are declared after socketfd, so they flush and destruct while the fd is still open, then ScopedFd closes it. --- src/modules/niri/backend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/niri/backend.cpp b/src/modules/niri/backend.cpp index 460754cc..19eeada0 100644 --- a/src/modules/niri/backend.cpp +++ b/src/modules/niri/backend.cpp @@ -285,7 +285,7 @@ void IPC::unregisterForIPC(EventHandler* ev_handler) { Json::Value IPC::send(const Json::Value& request) { util::ScopedFd socketfd(connectToSocket()); - auto unix_istream = Gio::UnixInputStream::create(socketfd, true); + auto unix_istream = Gio::UnixInputStream::create(socketfd, false); auto unix_ostream = Gio::UnixOutputStream::create(socketfd, false); auto istream = Gio::DataInputStream::create(unix_istream); auto ostream = Gio::DataOutputStream::create(unix_ostream);