From c58be606dd6df5634a4cd4835033c64bc9d112fe Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Apr 2021 14:54:38 -0700 Subject: [PATCH] QLockFile/Unix: remove the " (deleted)" suffix from kernel-supplied names The kernel appends that to the symlink targets in /proc for files that have been deleted. Change-Id: I7a386ad4f0cb4e2ba629fffd16789b5a52491627 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qlockfile_unix.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index b531140437..fb728144a4 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -238,6 +238,12 @@ QString QLockFilePrivate::processNameByPid(qint64 pid) // The pid is gone. Return some invalid process name to fail the test. return QStringLiteral("/ERROR/"); } + + // remove the " (deleted)" suffix, if any + static const char deleted[] = " (deleted)"; + if (buf.endsWith(deleted)) + buf.chop(strlen(deleted)); + return QFileInfo(QFile::decodeName(buf)).fileName(); #elif defined(Q_OS_HAIKU) thread_info info;