From: David Carlier Date: Tue, 17 Aug 2021 07:44:25 +0000 (+0100) Subject: BUILD: tools: get the absolute path of the current binary on NetBSD. X-Git-Tag: v2.5-dev4~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd2ccedcc51d622598644179788d7dca37e8f6d3;p=thirdparty%2Fhaproxy.git BUILD: tools: get the absolute path of the current binary on NetBSD. NetBSD stores the absolute path into the auxiliary vector as well. --- 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; }