mirror of
https://github.com/hyprwm/Hyprland.git
synced 2026-08-18 11:02:10 +00:00
internal: replace O_CLOEXEC with FD_CLOEXEC for file descriptor flags (#14909)
* refactor: replace O_CLOEXEC with FD_CLOEXEC for file descriptor flags * chore: remove local clangd config from PR --------- Co-authored-by: Pppp1116 <pcaiadoguerreiro@gmail.com>
This commit is contained in:
@ -140,7 +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);
|
||||
m_watchdogWriteFd.setFlags(m_watchdogWriteFd.getFlags() | FD_CLOEXEC);
|
||||
return m_watchdogWriteFd.isValid() && !m_watchdogWriteFd.isClosed();
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include "../../ConfigValue.hpp"
|
||||
#include "../../ConfigManager.hpp"
|
||||
#include <ranges>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <filesystem>
|
||||
|
||||
@ -19,19 +18,11 @@ UP<CConfigWatcher>& Config::watcher() {
|
||||
return p;
|
||||
}
|
||||
|
||||
CConfigWatcher::CConfigWatcher() : m_inotifyFd(inotify_init()) {
|
||||
CConfigWatcher::CConfigWatcher() : m_inotifyFd(inotify_init1(IN_NONBLOCK | IN_CLOEXEC)) {
|
||||
if (!m_inotifyFd.isValid()) {
|
||||
Log::logger->log(Log::ERR, "CConfigWatcher couldn't open an inotify node. Config will not be automatically reloaded");
|
||||
return;
|
||||
}
|
||||
|
||||
// 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 | 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;
|
||||
}
|
||||
}
|
||||
|
||||
CFileDescriptor& CConfigWatcher::getInotifyFD() {
|
||||
|
||||
@ -155,9 +155,9 @@ 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);
|
||||
m_fromHlPid.setFlags(m_fromHlPid.getFlags() | FD_CLOEXEC);
|
||||
m_wakeupRead.setFlags(m_wakeupRead.getFlags() | FD_CLOEXEC);
|
||||
m_wakeupWrite.setFlags(m_wakeupWrite.getFlags() | FD_CLOEXEC);
|
||||
|
||||
runHyprlandThread(safeMode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user