From 59b3273cf7160469635b0da8bf4093299251b66e Mon Sep 17 00:00:00 2001 From: Ye ShanShan Date: Mon, 9 Dec 2024 18:26:42 +0800 Subject: [PATCH] fix: pidfd leak pidfd must be closed by caller according QDBusUnixFileDescriptor. pms: BUG-293049 --- src/dsgapplication.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dsgapplication.cpp b/src/dsgapplication.cpp index 2c8a20c5..eafabeee 100644 --- a/src/dsgapplication.cpp +++ b/src/dsgapplication.cpp @@ -100,7 +100,7 @@ QByteArray DSGApplication::getId(qint64 pid) int pidfd = syscall(SYS_pidfd_open, pid, 0); if (pidfd < 0) { - qCWarning(dsgApp) << "pidfd open failed:" << strerror(errno); + qCWarning(dsgApp) << "pidfd open failed:" << strerror(errno) << ", the pid:" << pid; return QByteArray(); } @@ -109,6 +109,8 @@ QByteArray DSGApplication::getId(qint64 pid) "org.desktopspec.ApplicationManager1"); QDBusReply reply = infc.call("Identify", QVariant::fromValue(QDBusUnixFileDescriptor(pidfd))); + // see QDBusUnixFileDescriptor: The original file descriptor is not touched and must be closed by the user. + close(pidfd); if (!reply.isValid()) { qCWarning(dsgApp) << "Identify from AM failed." << reply.error().message();