Skip to content

Commit a2b0fb9

Browse files
committed
fix: handle failure in resolving executable path for process ID
- Added error handling for the case when the executable path cannot be resolved from the /proc/{pid}/exe symlink. - Log a warning message when the resolution fails, improving debugging capabilities. Log: Enhance robustness in process ID executable path resolution.
1 parent b24aa34 commit a2b0fb9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

deepin-system-monitor-system-server/src/systemdbusserver.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ static QString getProcIdExe(qint64 id)
4646
// Read contents of virtual /proc/{pid}/cmdline file
4747
QString exeSymlinkPath = QString("/proc/%1/exe").arg(id);
4848
char *actualpath = realpath(exeSymlinkPath.toStdString().c_str(), nullptr);
49-
execName = QString(actualpath);
49+
if (actualpath) {
50+
execName = QString(actualpath);
51+
free(actualpath); // free the memory allocated by realpath
52+
} else {
53+
qWarning() << "Failed to resolve path for PID" << id;
54+
}
5055
}
5156
return execName;
5257
}

0 commit comments

Comments
 (0)