Add missing get_exe_filename() implementation for FreeBSD

This commit is contained in:
Alexey Dokuchaev
2022-11-13 19:47:32 +01:00
committed by Guldoman
parent 1590be8c8d
commit 1b1c13e3de
+8 -1
View File
@@ -7,11 +7,14 @@
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#elif __linux__ || __FreeBSD__ #elif __linux__
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#elif __APPLE__ #elif __APPLE__
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#elif __FreeBSD__
#include <sys/sysctl.h>
#include <signal.h>
#endif #endif
@@ -43,6 +46,10 @@ static void get_exe_filename(char *buf, int sz) {
char exepath[size]; char exepath[size];
_NSGetExecutablePath(exepath, &size); _NSGetExecutablePath(exepath, &size);
realpath(exepath, buf); realpath(exepath, buf);
#elif __FreeBSD__
size_t len = sz;
const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
sysctl(mib, 4, buf, &len, NULL, 0);
#else #else
strcpy(buf, "./lite"); strcpy(buf, "./lite");
#endif #endif