From bd6956d52ffc950102613b7425eb30f668206888 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 19 Aug 2024 17:22:30 +0200 Subject: [PATCH] (FreeBSD) Added fallback method to locate binary --- es-core/src/utils/FileSystemUtil.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index e6aecc205..ae9b10f6a 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -375,6 +375,14 @@ namespace Utils esBinary = exePath; exePath = getCanonicalPath(exePath); +#if defined(__FreeBSD__) + // Fallback to getPathToBinary(argv[0]), needed as FreeBSD does not typically + // provide /proc/self/exe. + if (exePath.empty()) { + esBinary = getPathToBinary(path); + exePath = getCanonicalPath(esBinary); + } +#endif // Fallback to argv[0] if everything else fails. if (exePath.empty()) { esBinary = path;