diff --git a/src/tools.c b/src/tools.c index bd6bf4edc0..545fd9e8dc 100644 --- a/src/tools.c +++ b/src/tools.c @@ -16,6 +16,11 @@ #include #endif +#if defined(__NetBSD__) +#include +#include +#endif + #include #include #include @@ -4761,6 +4766,14 @@ const char *get_exec_path() if (execfn && execfn != ENOENT) ret = (const char *)execfn; +#elif defined(__NetBSD__) + AuxInfo *auxv; + for (auxv = _dlauxinfo(); auxv->a_type != AT_NULL; ++auxv) { + if (auxv->a_type == AT_SUN_EXECNAME) { + ret = (const char *)auxv->a_v; + break; + } + } #endif return ret; }