Commit 1ce42414 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Use readlink instead of QFileInfo to prevent non-responsive issues.

The current code using QFileInfo on the /proc/%pid/cwd and for some
situations, this may cause issues as QFileInfo hangs if unable to read that
file.  The new code uses readlink which appears to work w/o issue.

The Solaris  code needs fixed as well.

CCBUG: 251351
parent d7f55a20
......@@ -29,6 +29,7 @@
#include <arpa/inet.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/param.h>
// Qt
#include <QtCore/QDir>
......@@ -557,21 +558,22 @@ private:
}
virtual bool readCurrentDir(int aPid) {
QFileInfo info(QString("/proc/%1/cwd").arg(aPid));
char path_buffer[MAXPATHLEN + 1];
path_buffer[MAXPATHLEN] = 0;
QByteArray procCwd = QFile::encodeName(QString("/proc/%1/cwd").arg(aPid));
const int length = readlink(procCwd.constData(), path_buffer, MAXPATHLEN);
if (length == -1) {
setError(UnknownError);
return false;
}
const bool readable = info.isReadable();
path_buffer[length] = '\0';
QString path = QFile::decodeName(path_buffer);
if (readable && info.isSymLink()) {
setCurrentDir(info.symLinkTarget());
return true;
} else {
if (!readable)
setError(PermissionsError);
else
setError(UnknownError);
kWarning()<<length<<";"<<path;
return false;
}
setCurrentDir(path);
return true;
}
virtual bool readEnvironment(int aPid) {
......@@ -873,6 +875,8 @@ private:
return false;
}
// FIXME: This will have the same issues as BKO 251351; the Linux
// version uses readlink.
virtual bool readCurrentDir(int aPid) {
QFileInfo info(QString("/proc/%1/path/cwd").arg(aPid));
const bool readable = info.isReadable();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment