X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=sys_shared.c;h=0db4c03479474e7fd81432ecb3f708d9e546111c;hb=5953522471ba6320e5c0ff2feebb9541c11995ee;hp=5171b34efaa180ead097559b1e4f835efab6b6dc;hpb=1b5e3869f0fd3e2fe323680784610d48d6efddca;p=xonotic%2Fdarkplaces.git diff --git a/sys_shared.c b/sys_shared.c index 5171b34e..0db4c034 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -18,6 +18,9 @@ #pragma comment(lib, "winmm.lib") #endif #else +# ifdef __FreeBSD__ +# include +# endif # include # include # include @@ -498,7 +501,12 @@ 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); + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; + size_t exenamebuflen = sizeof(exenamebuf)-1; + if (sysctl(mib, 4, exenamebuf, &exenamebuflen, NULL, 0) == 0) + { + n = exenamebuflen; + } #elif defined(__linux__) n = readlink("/proc/self/exe", exenamebuf, sizeof(exenamebuf)-1); #endif