From b885dc9f271a39254d09f0f6be9bda9142c9031b Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Mon, 8 Jun 2026 01:11:12 +0300 Subject: [PATCH] Implement getexepath for OpenBSD --- src/native/minipal/getexepath.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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)