]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: tools: get the absolute path of the current binary on NetBSD.
authorDavid Carlier <devnexen@gmail.com>
Tue, 17 Aug 2021 07:44:25 +0000 (08:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 17 Aug 2021 07:54:28 +0000 (09:54 +0200)
NetBSD stores the absolute path into the auxiliary vector as well.

src/tools.c

index bd6bf4edc065a61f11280d9e35d88d3ca49eea45..545fd9e8dca241e5d7c24fb4f4585d970447f75f 100644 (file)
 #include <link.h>
 #endif
 
+#if defined(__NetBSD__)
+#include <sys/exec_elf.h>
+#include <dlfcn.h>
+#endif
+
 #include <ctype.h>
 #include <errno.h>
 #include <netdb.h>
@@ -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;
 }