Processing (Linux): don't use /proc/pid/exe as exePath when the file is not executable (no permission)

This commit is contained in:
Carter Li
2026-06-11 10:15:25 +08:00
parent 4594734b66
commit 52970e2d13
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ static void getExePath(FFPlatform* platform) {
char exePath[PATH_MAX];
#if defined(__linux__) || defined(__GNU__)
ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1);
if (exePathLen >= 0) {
if (exePathLen > 0) {
exePath[exePathLen] = '\0';
}
#elif defined(__APPLE__)
@@ -128,7 +128,7 @@ static void getExePath(FFPlatform* platform) {
}
#elif defined(__sun)
ssize_t exePathLen = readlink("/proc/self/path/a.out", exePath, sizeof(exePath) - 1);
if (exePathLen >= 0) {
if (exePathLen > 0) {
exePath[exePathLen] = '\0';
}
#elif defined(__HAIKU__)
+1 -1
View File
@@ -269,7 +269,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
}
}
if (exePath->length == 0) {
if (exePath->length == 0 && access(filePath, X_OK) == 0) {
ffStrbufSetS(exePath, filePath);
}
}