diff --git a/logind.cpp b/logind.cpp index 4a86d77e03..c300cac675 100644 --- a/logind.cpp +++ b/logind.cpp @@ -36,6 +36,7 @@ along with this program. If not, see . #ifndef major #include #endif +#include #include #include "utils.h" @@ -378,7 +379,9 @@ int LogindIntegration::takeDevice(const char *path) qCDebug(KWIN_CORE) << "Could not take device" << path << ", cause: " << reply.errorMessage(); return -1; } - return dup(reply.arguments().first().value().fileDescriptor()); + + // The dup syscall removes the CLOEXEC flag as a side-effect. So use fcntl's F_DUPFD_CLOEXEC cmd. + return fcntl(reply.arguments().first().value().fileDescriptor(), F_DUPFD_CLOEXEC, 0); } void LogindIntegration::releaseDevice(int fd)