From 50fb8bfb033dadb90084f7a3b5bbddec4e5dd1a1 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Fri, 7 Aug 2009 13:01:33 +0200
Subject: [PATCH] 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).
---
 src/plugins/debugger/debuggerdialogs.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp
index 2d7161412dd..c8251ea9b69 100644
--- a/src/plugins/debugger/debuggerdialogs.cpp
+++ b/src/plugins/debugger/debuggerdialogs.cpp
@@ -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;
-- 
GitLab