From 3699e50e003549b9b19955e07516753cd90a665a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Fri, 20 Nov 2020 15:49:57 -0600 Subject: [PATCH] Explicitly check for KERN_PROC_PATHNAME While FreeBSD, DragonflyBSD, and NetBSD have KERN_PROC_PATHNAME, OpenBSD does not. --- src/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.cpp b/src/common.cpp index 7dad9f72d..f30b81e2f 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1995,7 +1995,7 @@ std::string get_executable_path(const char *argv0) { // https://opensource.apple.com/source/adv_cmds/adv_cmds-163/ps/print.c uint32_t buffSize = sizeof buff; if (_NSGetExecutablePath(buff, &buffSize) == 0) return std::string(buff); -#elif defined(__BSD__) +#elif defined(__BSD__) && defined(KERN_PROC_PATHNAME) // BSDs do not have /proc by default, (although it can be mounted as procfs via the Linux // compatibility layer). We can use sysctl instead: per sysctl(3), passing in a process ID of -1 // returns the value for the current process.