Fix leaking of FDs requested from logind
Summary: The takeDevice method calls dup, but that syscall removes the O_CLOEXEC flag as a side-effect. This resulted in all child processes of kwin_wayland having an open file descriptor for those devices. Test Plan: Looked at the open FDs of the startplasma script. Before, all /dev/input/eventX files and /dev/dri/card0 were open. Now, none of those are part of /proc/PID/fd/ Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: kwin, plasma-devel, #kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D8887
This commit is contained in:
parent
d7d78e2b59
commit
96af5965ee
1 changed files with 4 additions and 1 deletions
|
@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifndef major
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#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<QDBusUnixFileDescriptor>().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<QDBusUnixFileDescriptor>().fileDescriptor(), F_DUPFD_CLOEXEC, 0);
|
||||
}
|
||||
|
||||
void LogindIntegration::releaseDevice(int fd)
|
||||
|
|
Loading…
Reference in a new issue