diff --git a/src/native/minipal/getexepath.h b/src/native/minipal/getexepath.h index eaf88f27e6a5ee..dbcf58e554727d 100644 --- a/src/native/minipal/getexepath.h +++ b/src/native/minipal/getexepath.h @@ -15,6 +15,10 @@ #include #include #include +#elif defined(__OpenBSD__) +#include +#include +#include #elif defined(_WIN32) #include #elif defined(__HAIKU__) @@ -57,6 +61,16 @@ static inline char* minipal_getexepath(void) } return strdup(path); +#elif defined(__OpenBSD__) + const int name[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; + void *argv[PATH_MAX]; + size_t len = sizeof(argv); + if (sysctl(name, 4, argv, &len, NULL, 0) != 0) + { + return NULL; + } + + return realpath((char *)argv[0], NULL); #elif defined(__sun) const char* path = getexecname(); if (path == NULL)