Skip to content

Commit

Permalink
fix: pidfd leak
Browse files Browse the repository at this point in the history
pidfd must be closed by caller according QDBusUnixFileDescriptor.

pms: BUG-293049
  • Loading branch information
18202781743 committed Dec 10, 2024
1 parent 7b15212 commit 53be287
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dsgapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -109,6 +109,8 @@ QByteArray DSGApplication::getId(qint64 pid)
"org.desktopspec.ApplicationManager1");

QDBusReply<QString> 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();
Expand Down

0 comments on commit 53be287

Please sign in to comment.