Skip to content
Snippets Groups Projects
Commit 50fb8bfb authored by Thiago Macieira's avatar Thiago Macieira
Browse files

Don't crash when the /proc/<pid>/stat file failed to open.

This may happen if a process exits after we got the /proc listing. If
we fail to open the file, readAll() returns empty, which means split()
returns an empty list, which means you can't do at(1).
parent bd660f9b
No related branches found
No related tags found
No related merge requests found
...@@ -197,7 +197,9 @@ static QList<ProcData> unixProcessList() ...@@ -197,7 +197,9 @@ static QList<ProcData> unixProcessList()
filename += procId; filename += procId;
filename += QLatin1String("/stat"); filename += QLatin1String("/stat");
QFile file(filename); QFile file(filename);
file.open(QIODevice::ReadOnly); if (!file.open(QIODevice::ReadOnly))
continue; // process may have exited
const QStringList data = QString::fromLocal8Bit(file.readAll()).split(' '); const QStringList data = QString::fromLocal8Bit(file.readAll()).split(' ');
ProcData proc; ProcData proc;
proc.ppid = procId; proc.ppid = procId;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment