On Tue, 08 Sep 2026 00:44:20 +0200,
Stuart Henderson <[email protected]> wrote:
>
> On 2026/09/03 23:22, Kirill A. Korinsky wrote:
> > I'd like to migrate our rust to use of getexecpath(), it should allow to
> > drop a lot of patches to remove usage of current_exe()
>
> If anyone knows a bit of C++ and has time, one of the other common
> implementations of path lookup for the current executable is in Boost,
> https://github.com/boostorg/dll/blob/HEAD/include/boost/dll/detail/posix/program_location_impl.hpp#L53
>
I not follow the modern C++ well enough, but I think it needs something like
that:
diff --git a/include/boost/dll/detail/posix/program_location_impl.hpp
b/include/boost/dll/detail/posix/program_location_impl.hpp
index 500afc6..b15ad4b 100644
--- a/include/boost/dll/detail/posix/program_location_impl.hpp
+++ b/include/boost/dll/detail/posix/program_location_impl.hpp
@@ -113,6 +113,30 @@ namespace boost { namespace dll { namespace detail {
+#elif BOOST_OS_BSD_OPEN
+
+#if !defined(BOOST_DLL_INTERFACE_UNIT)
+#include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+#endif // !defined(BOOST_DLL_INTERFACE_UNIT)
+
+namespace boost { namespace dll { namespace detail {
+ inline boost::dll::fs::path program_location_impl(std::error_code& ec) {
+ ec.clear();
+
+ char path[PATH_MAX];
+ if (getexecpath(path, sizeof(path)) != 0) {
+ ec = std::make_error_code(
+ static_cast<std::errc>(errno)
+ );
+ return boost::dll::fs::path();
+ }
+
+ return boost::dll::fs::path(path);
+ }
+}}} // namespace boost::dll::detail
+
#elif BOOST_OS_BSD_NET
namespace boost { namespace dll { namespace detail {
--
wbr, Kirill