From: David CARLIER Date: Sun, 20 Feb 2022 16:28:58 +0000 (+0000) Subject: Sys_FindExecutableName FreeBSD fix. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fmerge-requests%2F128%2Fhead;p=xonotic%2Fdarkplaces.git Sys_FindExecutableName FreeBSD fix. Retrieving the path via native API rather than the optional presence of the procfs support. --- diff --git a/sys_shared.c b/sys_shared.c index f1c0d60c..b8b26917 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -24,6 +24,9 @@ # ifdef SUPPORTDLL # include # endif +# ifdef __FreeBSD__ +# include +# endif #endif static char sys_timestring[128]; @@ -493,7 +496,10 @@ static const char *Sys_FindExecutableName(void) static char exenamebuf[MAX_OSPATH+1]; ssize_t n = -1; #if defined(__FreeBSD__) - n = readlink("/proc/curproc/file", exenamebuf, sizeof(exenamebuf)-1); + size_t l = sizeof(exenamebuf); + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; + if (sysctl(mib, 4, exenamebuf, &l, NULL, 0) == 0) + n = (ssize_t)l; #elif defined(__linux__) n = readlink("/proc/self/exe", exenamebuf, sizeof(exenamebuf)-1); #endif