Verified Commit bfb81a61 authored by Thomas Klausner's avatar Thomas Klausner Committed by Marc Jeanmougin
Browse files

Implement get_program_name() for NetBSD.

parent 160dc740
Pipeline #367457364 canceled with stages
in 2 minutes and 36 seconds
......@@ -20,6 +20,11 @@
#include <mach-o/dyld.h> // for _NSGetExecutablePath
#endif
#ifdef __NetBSD__
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#include <cassert>
#include <glib.h>
#include <glibmm.h>
......@@ -123,6 +128,15 @@ char const *get_program_name()
if (!program_name) {
g_warning("get_program_name() - g_file_read_link failed");
}
#elif defined(__NetBSD__)
static const int name[] = {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME};
char path[MAXPATHLEN];
size_t len = sizeof(path);
if (sysctl(name, __arraycount(name), path, &len, NULL, 0) == 0) {
program_name = realpath(path, 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