From 08dfd1321c9667ad30a5b6c4933bc64d68343cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 26 Feb 2026 15:12:53 +0800 Subject: [PATCH] Platform (macOS): use `_NSGetExecutablePath` to query current exe path Unlike proc_pidpath which uses syscall --- src/common/impl/FFPlatform_unix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/impl/FFPlatform_unix.c b/src/common/impl/FFPlatform_unix.c index 8e590dd34..c93c863bd 100644 --- a/src/common/impl/FFPlatform_unix.c +++ b/src/common/impl/FFPlatform_unix.c @@ -12,7 +12,7 @@ #include #ifdef __APPLE__ - #include + #include #include #elif defined(__FreeBSD__) || defined(__NetBSD__) #include @@ -33,7 +33,11 @@ static void getExePath(FFPlatform* platform) if (exePathLen >= 0) exePath[exePathLen] = '\0'; #elif defined(__APPLE__) - int exePathLen = proc_pidpath((pid_t) platform->pid, exePath, sizeof(exePath)); + uint32_t exePathLen = sizeof(exePath); + if (_NSGetExecutablePath(exePath, &exePathLen) == 0) + exePathLen = (uint32_t) strlen(exePath); + else + exePathLen = 0; #elif defined(__FreeBSD__) || defined(__NetBSD__) size_t exePathLen = sizeof(exePath); if(sysctl(