This commit is contained in:
Sergey Fedorov 2025-12-18 09:50:17 +05:30 committed by GitHub
commit bdfbca1196
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -1,6 +1,11 @@
#pragma once
#include <fcntl.h>
#ifndef F_DUPFD_CLOEXEC
#define F_DUPFD_CLOEXEC F_DUPFD
#endif
namespace Hyprutils {
namespace OS {
class CFileDescriptor {

View file

@ -55,7 +55,14 @@ CFileDescriptor CFileDescriptor::duplicate(int flags) const {
if (m_fd == -1)
return {};
return CFileDescriptor{fcntl(m_fd, flags, 0)};
int new_fd;
#ifdef F_DUPFD_CLOEXEC
new_fd = fcntl(m_fd, flags, 0);
#else
new_fd = fcntl(m_fd, flags | FD_CLOEXEC, 0);
#endif
return CFileDescriptor{new_fd};
}
bool CFileDescriptor::isClosed() const {