[Libreoffice-commits] core.git: sal/osl
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Oct 23 10:27:14 UTC 2018
sal/osl/unx/process_impl.cxx | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
New commits:
commit bdb10815a6003052417421e2b1eb1faf61f52931
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Mon Oct 22 22:00:49 2018 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 23 12:26:51 2018 +0200
dlsym() typically does not find "main" so use readlink() on /proc/self/exe
Change-Id: I37b77fbc393b743fd508b7e3330409e90c7097b9
Reviewed-on: https://gerrit.libreoffice.org/62196
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx
index f7397d48f242..b232695cd57f 100644
--- a/sal/osl/unx/process_impl.cxx
+++ b/sal/osl/unx/process_impl.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <osl/diagnose.h>
-#include <osl/file.h>
+#include <osl/file.hxx>
#include <osl/module.h>
#include <osl/thread.h>
#include <rtl/alloc.h>
@@ -100,6 +100,26 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** ppFileURL)
* any */
void * addr = dlsym (RTLD_DEFAULT, "JNI_OnLoad");
#else
+#if defined __linux
+ // The below code looking for "main" with dlsym() will typically
+ // fail, as there is little reason for "main" to be exported, in
+ // the dlsym() sense, from an executable. But Linux has
+ // /proc/self/exe, try using that.
+ char buf[PATH_MAX];
+ int rc = readlink("/proc/self/exe", buf, sizeof(buf));
+ if (rc > 0 && rc < PATH_MAX)
+ {
+ buf[rc] = '\0';
+ OUString path = OUString::fromUtf8(buf);
+ OUString fileURL;
+ if (osl::File::getFileURLFromSystemPath(path, fileURL) == osl::File::E_None)
+ {
+ rtl_uString_acquire(fileURL.pData);
+ *ppFileURL = fileURL.pData;
+ return osl_Process_E_None;
+ }
+ }
+#endif
/* Determine address of "main()" function. */
void * addr = dlsym (RTLD_DEFAULT, "main");
#endif
More information about the Libreoffice-commits
mailing list