summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qlockfile_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-06-30 13:30:52 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-07-08 02:18:16 +0000
commit80c152d6898c1b8727ac14d32437b274153a7089 (patch)
tree78d2b98bac5cd3e6a4395e8e86ce7fb68f3ec0fa /src/corelib/io/qlockfile_unix.cpp
parent3c689c4b3fd24ead8726444723536452d0e89d85 (diff)
Move the readlink(2) wrapper to qcore_unix.cpp
This deduplicates the code between QFileSystemEngine and QLockFile. Change-Id: I1eba2b016de74620bfc8fffd14cd005d5fd9beaa Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Diffstat (limited to 'src/corelib/io/qlockfile_unix.cpp')
-rw-r--r--src/corelib/io/qlockfile_unix.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index f21aced87c..1ee8ce889c 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -260,15 +260,15 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
#elif defined(Q_OS_LINUX)
if (!qt_haveLinuxProcfs())
return QString();
+
char exePath[64];
- char buf[PATH_MAX + 1];
sprintf(exePath, "/proc/%lld/exe", pid);
- size_t len = (size_t)readlink(exePath, buf, sizeof(buf));
- if (len >= sizeof(buf)) {
+
+ QByteArray buf = qt_readlink(exePath);
+ if (buf.isEmpty()) {
// The pid is gone. Return some invalid process name to fail the test.
return QStringLiteral("/ERROR/");
}
- buf[len] = 0;
return QFileInfo(QFile::decodeName(buf)).fileName();
#elif defined(Q_OS_HAIKU)
thread_info info;