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).
This commit is contained in:
Thiago Macieira
2009-08-07 13:01:33 +02:00
parent bd660f9b69
commit 50fb8bfb03

View File

@@ -197,7 +197,9 @@ static QList<ProcData> unixProcessList()
filename += procId;
filename += QLatin1String("/stat");
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(' ');
ProcData proc;
proc.ppid = procId;