Verified Commit 06b1437e authored by Tobias C. Berner's avatar Tobias C. Berner Committed by Marc Jeanmougin
Browse files

Add FreeBSD support

parent ae585928
Pipeline #367461076 canceled with stages
in 6 minutes and 43 seconds
......@@ -25,6 +25,12 @@
#include <sys/sysctl.h>
#endif
#ifdef __FreeBSD__
#include <sys/param.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#include <cassert>
#include <glib.h>
#include <glibmm.h>
......@@ -137,6 +143,15 @@ char const *get_program_name()
} else {
g_warning("get_program_name() - sysctl failed");
}
#elif defined(__FreeBSD__)
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
char buf[MAXPATHLEN];
size_t cb = sizeof(buf);
if (sysctl(mib, 4, buf, &cb, NULL, 0) == 0) {
program_name = realpath(buf, nullptr);
} else {
g_warning("get_program_name() - sysctl failed");
}
#else
#warning get_program_name() - no known way to obtain executable name on this platform
g_info("get_program_name() - no known way to obtain executable name on this platform");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment