summaryrefslogtreecommitdiff
path: root/java/openjdk8/files/patch-jdk-src-solaris-bin-java_md_solinux.c
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2015-07-02 18:17:12 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2015-07-02 18:17:12 +0000
commitfd492a9fe58ced43c5eabe67dfd48decda3f0bdb (patch)
treeac072eb103a9265ad59f58a53e067f84db698d3d /java/openjdk8/files/patch-jdk-src-solaris-bin-java_md_solinux.c
parentUpdate to 0.9.15, move to Github and add LICENSE. (diff)
- Fix broken preprocessor directives.
- Use sysctl(3) instead of procfs(5) when we need executable path from PID. MFH: 2015Q3
Notes
Notes: svn path=/head/; revision=391177
Diffstat (limited to 'java/openjdk8/files/patch-jdk-src-solaris-bin-java_md_solinux.c')
-rw-r--r--java/openjdk8/files/patch-jdk-src-solaris-bin-java_md_solinux.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/java/openjdk8/files/patch-jdk-src-solaris-bin-java_md_solinux.c b/java/openjdk8/files/patch-jdk-src-solaris-bin-java_md_solinux.c
new file mode 100644
index 000000000000..c858a0c14fc1
--- /dev/null
+++ b/java/openjdk8/files/patch-jdk-src-solaris-bin-java_md_solinux.c
@@ -0,0 +1,53 @@
+--- jdk/src/solaris/bin/java_md_solinux.c.orig
++++ jdk/src/solaris/bin/java_md_solinux.c
+@@ -35,6 +35,9 @@
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <sys/types.h>
++#ifdef __FreeBSD__
++#include <sys/sysctl.h>
++#endif
+ #include "manifest_info.h"
+ #include "version_comp.h"
+
+@@ -925,7 +928,7 @@
+ * 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.
+- * On FreeBSD we read the executable name from /proc/curproc/file.
++ * On FreeBSD, we get the executable name via sysctl(3).
+ * As a fallback, and for platforms other than Solaris, Linux, and
+ * FreeBSD, we use FindExecName to compute the executable name.
+ */
+@@ -954,13 +957,9 @@
+ }
+ }
+ }
+-#elif defined(__linux__) || defined(__FreeBSD__)
++#elif defined(__linux__)
+ {
+-#if defined(__FreeBSD__)
+- 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) {
+@@ -968,6 +967,16 @@
+ exec_path = JLI_StringDup(buf);
+ }
+ }
++#elif defined(__FreeBSD__)
++ {
++ char buf[PATH_MAX+1];
++ int name[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
++ size_t len = sizeof(buf);
++ if (sysctl(name, 4, buf, &len, NULL, 0) == 0 && len > 0) {
++ buf[len] = '\0';
++ exec_path = JLI_StringDup(buf);
++ }
++ }
+ #else /* !__solaris__ && !__linux__ && !__FreeBSD__ */
+ {
+ /* Not implemented */