core: fix a few fd leaks (#14870)

* core: fix a few fd leaks

ref #14839

* core: fix a few fd leaks

ref #14839
This commit is contained in:
Vaxry
2026-06-07 12:26:02 +02:00
committed by Vaxry
parent f898323082
commit fc8c353598
3 changed files with 6 additions and 1 deletions
+1
View File
@@ -140,6 +140,7 @@ static void handleUserSignal(int sig) {
bool CCompositor::setWatchdogFd(int fd) {
m_watchdogWriteFd = Hyprutils::OS::CFileDescriptor{fd};
m_watchdogWriteFd.setFlags(m_watchdogWriteFd.getFlags() | O_CLOEXEC);
return m_watchdogWriteFd.isValid() && !m_watchdogWriteFd.isClosed();
}
+1 -1
View File
@@ -27,7 +27,7 @@ CConfigWatcher::CConfigWatcher() : m_inotifyFd(inotify_init()) {
// TODO: make CFileDescriptor take F_GETFL, F_SETFL
const int FLAGS = fcntl(m_inotifyFd.get(), F_GETFL, 0);
if (fcntl(m_inotifyFd.get(), F_SETFL, FLAGS | O_NONBLOCK) < 0) {
if (fcntl(m_inotifyFd.get(), F_SETFL, FLAGS | O_NONBLOCK | O_CLOEXEC) < 0) {
Log::logger->log(Log::ERR, "CConfigWatcher couldn't non-block inotify node. Config will not be automatically reloaded");
m_inotifyFd.reset();
return;
+4
View File
@@ -155,6 +155,10 @@ bool CHyprlandInstance::run(bool safeMode) {
m_wakeupRead = CFileDescriptor{pipefds[0]};
m_wakeupWrite = CFileDescriptor{pipefds[1]};
m_fromHlPid.setFlags(m_fromHlPid.getFlags() | O_CLOEXEC);
m_wakeupRead.setFlags(m_wakeupRead.getFlags() | O_CLOEXEC);
m_wakeupWrite.setFlags(m_wakeupWrite.getFlags() | O_CLOEXEC);
runHyprlandThread(safeMode);
pollfd pollfds[2] = {