changeset 7351:beba30cbaff8

. Use /proc/curproc/file to find the executable path, if available. This helps with the icedtea web code being used in ports for the browser plugin and javaws. Submitted by: jkim@FreeBSD.org
author Greg Lewis <glewis@eyesbeyond.com>
date Sat, 07 Jun 2014 00:19:05 -0700
parents 457de21d8b76
children 3730487baa2a
files src/solaris/bin/java_md_solinux.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/bin/java_md_solinux.c	Fri Jun 06 19:56:38 2014 -0700
+++ b/src/solaris/bin/java_md_solinux.c	Sat Jun 07 00:19:05 2014 -0700
@@ -899,8 +899,9 @@
  * onwards the filename returned in DL_info structure from dladdr is
  * an absolute pathname so technically realpath isn't required.
  * On Linux we read the executable name from /proc/self/exe.
- * As a fallback, and for platforms other than Solaris and Linux,
- * we use FindExecName to compute the executable name.
+ * On *BSD we read the executable name from /proc/curproc/file.
+ * As a fallback, and for platforms other than Solaris, Linux, and
+ * *BSD, we use FindExecName to compute the executable name.
  */
 const char*
 SetExecname(char **argv)
@@ -927,9 +928,13 @@
             }
         }
     }
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(_ALLBSD_SOURCE)
     {
+#if defined(_ALLBSD_SOURCE)
+        const char* self = "/proc/curproc/file";
+#else
         const char* self = "/proc/self/exe";
+#endif
         char buf[PATH_MAX+1];
         int len = readlink(self, buf, PATH_MAX);
         if (len >= 0) {
@@ -937,7 +942,7 @@
             exec_path = JLI_StringDup(buf);
         }
     }
-#else /* !__solaris__ && !__linux__ */
+#else /* !__solaris__ && !__linux__ && !_ALLBSD_SOURCE */
     {
         /* Not implemented */
     }