From 03aab33507ecdfee90962501392aec9bf9d82183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 9 Jan 2026 16:07:20 +0800 Subject: [PATCH] Shell (Linux): supports version detection for deleted binaries Fixes #2136 --- src/common/impl/processing_linux.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/impl/processing_linux.c b/src/common/impl/processing_linux.c index c270ab01a..ad76c6c00 100644 --- a/src/common/impl/processing_linux.c +++ b/src/common/impl/processing_linux.c @@ -222,6 +222,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons { assert(processName->length > 0); ffStrbufClear(exe); + if (exePath) ffStrbufClear(exePath); #if defined(__linux__) || defined(__GNU__) @@ -270,13 +271,14 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons if (length > 0) // doesn't contain trailing NUL { buf[length] = '\0'; - ffStrbufEnsureFixedLengthFree(exePath, (uint32_t)length); - ffStrbufAppendNS(exePath, (uint32_t)length, buf); + // When the process is a deleted executable, the resolved path is like `/usr/bin/app (deleted)` + // But we can still access the binary via `/proc/pid/exe`. See #2136 + if (ffPathExists(buf, FF_PATHTYPE_ANY)) + ffStrbufSetNS(exePath, (uint32_t)length, buf); } - else - { + + if (exePath->length == 0) ffStrbufSetS(exePath, filePath); - } } #elif defined(__APPLE__)