Re: performous FTBFS, it needs code to find the own executable
Hi!
On Mon, 2019-07-29 at 17:06:34 +0200, Thorsten Glaser wrote:
> It basically does this (I’m ignoring the boring stuff like Windows):
>
> #if (BOOST_OS_BSD)
> int mib[4];
> mib[0] = CTL_KERN;
> mib[1] = KERN_PROC;
> mib[2] = KERN_PROC_PATHNAME;
> mib[3] = -1;
> char buf[1024];
> size_t maxchars = sizeof(buf) - 1;
> size_t size = maxchars;
> sysctl(mib, 4, buf, &size, NULL, 0);
> if (size == 0 || size >= maxchars) return fs::path();
> buf[size] = '\0';
> return buf;
> #elif (BOOST_OS_LINUX)
> char buf[1024];
> ssize_t maxchars = sizeof(buf) - 1;
> ssize_t size = readlink("/proc/self/exe", buf, sizeof(buf));
> if (size <= 0 || size >= maxchars) return fs::path();
> buf[size] = '\0';
> return buf;
> #else
> return fs::path(); // which fails on Hurd
> #endif
>
> Two questions arise:
>
> ① Is one of the two right for Hurd, and if so, which,
> or is different code needed, and if so, which?
> (They hardcode 1024 for path length
> but this could be adapted.)
AFAIR BOOST_OS_LINUX might be OKish with recent Hurd proc servers, but
for start-stop-daemon I'm just using the native interfaces, see
<https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/utils/start-stop-daemon.c#n1749>,
which also needs to link against libps.
> ② What BOOST_OS_* is/are defined on Debian/Hurd?
Hmm, sorry do not have my Hurd system at hand right now. :)
Thanks,
Guillem
Reply to: