1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-21 20:38:45 +00:00

. Add fix for "runaway process" problem. It should fix of stalled

processes problem for people who use Runtime.getRuntime.exec() method
  and related things.  Least five people reported that this patch fixed
  problem for them.

  IMPORTANT: I'd also suggested to all jdk14 users who runs FreeBSD 4.x
  and use libc_r at FreeBSD 5.x to upgrade.

. Stop removing "src.zip" from installation bundle.  Since -p4 it builds
  correctly and there's no reason to forbit people to use it.

. Bump PORTREVISION.
This commit is contained in:
Alexey Zelkin 2003-10-29 08:20:59 +00:00
parent 1449be132b
commit 7d2d0599c7
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=92540
9 changed files with 285 additions and 6 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= jdk
PORTVERSION= ${JDK_VERSION}p${JDK_PATCHSET_VERSION}
PORTREVISION= 1
CATEGORIES= java devel
MASTER_SITES= # http://www.sun.com/software/java2/download.html
# http://www.eyesbeyond.com/freebsddom/java/jdk14.html
@ -211,8 +212,6 @@ post-build:
@# XXX make sure that SwingSet2/resources does not exists
@${RM} -rf ${JDKIMAGEDIR}/demo/jfc/SwingSet2/resources
@${RM} -rf ${JDKIMAGEDIR}/demo/plugin/jfc/SwingSet2/resources
@# This file serves no purpose (in case of port)
@${RM} -f ${JDKIMAGEDIR}/src.zip
.if !defined(NODEBUG)
pre-install:

View File

@ -0,0 +1,93 @@
$FreeBSD$
--- ../../j2se/src/solaris/native/java/lang/UNIXProcess_md.c.bsd.orig Wed Oct 29 12:22:58 2003
+++ ../../j2se/src/solaris/native/java/lang/UNIXProcess_md.c.bsd Wed Oct 29 12:23:33 2003
@@ -22,6 +22,12 @@
#include <errno.h>
#include <unistd.h>
+#if defined(__FreeBSD__)
+#include <dlfcn.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#endif
+
/* path in the environment */
static char **PATH = 0;
/* effective uid */
@@ -228,6 +234,61 @@
}
}
+#if defined(__FreeBSD__)
+
+extern pid_t __sys_fork(void);
+
+static pid_t
+jdk_fork_wrapper()
+{
+ pid_t resultPid;
+#if (__FreeBSD_version < 5)
+ static int is_libc_r = -1;
+ void *funcref;
+
+ if (is_libc_r == -1) {
+ is_libc_r = 1;
+
+ /*
+ * BSDNOTE: Check for loaded symbols.
+ *
+ * If "_thr_critical_enter" is found assume we are using 'libthr'.
+ * If _kse_critical_enter is found assume we are using 'libkse'.
+ * Otherwise we are using libc_r.
+ *
+ * If libc_r is loaded, use fork system call drectly to avoid
+ * problems with using protected pages.
+ *
+ * --phantom
+ */
+ funcref = dlsym(RTLD_DEFAULT, "_kse_critical_enter");
+ if (funcref != NULL)
+ is_libc_r = 0;
+ else {
+ funcref = dlsym(RTLD_DEFAULT, "_thr_critical_enter");
+ if (funcref != NULL)
+ is_libc_r = 0;
+ }
+ }
+
+ if (is_libc_r == 0) {
+ /* Not a libc_r */
+ resultPid = fork();
+ } else {
+#endif /* __FreeBSD_version < 5 */
+ pthread_suspend_all_np();
+ resultPid = __sys_fork();
+ if (resultPid != 0)
+ /* leave child in single threading mode */
+ pthread_resume_all_np();
+#if (__FreeBSD_version < 5)
+ }
+#endif /* __FreeBSD_version < 5 */
+
+ return resultPid;
+}
+#endif /* __FreeBSD__ */
+
JNIEXPORT jint JNICALL
Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env,
jobject process,
@@ -335,8 +396,12 @@
if (path != NULL) {
cwd = (char *)JNU_GetStringPlatformChars(env, path, NULL);
}
-
+
+#if defined(__FreeBSD__)
+ resultPid = jdk_fork_wrapper();
+#else
resultPid = fork();
+#endif
if (resultPid < 0) {
char errmsg[128];

View File

@ -2,6 +2,7 @@ jdk%%JDK_VERSION%%/COPYRIGHT
jdk%%JDK_VERSION%%/LICENSE
jdk%%JDK_VERSION%%/README
jdk%%JDK_VERSION%%/README.html
jdk%%JDK_VERSION%%/src.zip
jdk%%JDK_VERSION%%/bin/ControlPanel
jdk%%JDK_VERSION%%/bin/HtmlConverter
jdk%%JDK_VERSION%%/bin/appletviewer

View File

@ -7,6 +7,7 @@
PORTNAME= jdk
PORTVERSION= ${JDK_VERSION}p${JDK_PATCHSET_VERSION}
PORTREVISION= 1
CATEGORIES= java devel
MASTER_SITES= # http://www.sun.com/software/java2/download.html
# http://www.eyesbeyond.com/freebsddom/java/jdk14.html
@ -211,8 +212,6 @@ post-build:
@# XXX make sure that SwingSet2/resources does not exists
@${RM} -rf ${JDKIMAGEDIR}/demo/jfc/SwingSet2/resources
@${RM} -rf ${JDKIMAGEDIR}/demo/plugin/jfc/SwingSet2/resources
@# This file serves no purpose (in case of port)
@${RM} -f ${JDKIMAGEDIR}/src.zip
.if !defined(NODEBUG)
pre-install:

View File

@ -0,0 +1,93 @@
$FreeBSD$
--- ../../j2se/src/solaris/native/java/lang/UNIXProcess_md.c.bsd.orig Wed Oct 29 12:22:58 2003
+++ ../../j2se/src/solaris/native/java/lang/UNIXProcess_md.c.bsd Wed Oct 29 12:23:33 2003
@@ -22,6 +22,12 @@
#include <errno.h>
#include <unistd.h>
+#if defined(__FreeBSD__)
+#include <dlfcn.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#endif
+
/* path in the environment */
static char **PATH = 0;
/* effective uid */
@@ -228,6 +234,61 @@
}
}
+#if defined(__FreeBSD__)
+
+extern pid_t __sys_fork(void);
+
+static pid_t
+jdk_fork_wrapper()
+{
+ pid_t resultPid;
+#if (__FreeBSD_version < 5)
+ static int is_libc_r = -1;
+ void *funcref;
+
+ if (is_libc_r == -1) {
+ is_libc_r = 1;
+
+ /*
+ * BSDNOTE: Check for loaded symbols.
+ *
+ * If "_thr_critical_enter" is found assume we are using 'libthr'.
+ * If _kse_critical_enter is found assume we are using 'libkse'.
+ * Otherwise we are using libc_r.
+ *
+ * If libc_r is loaded, use fork system call drectly to avoid
+ * problems with using protected pages.
+ *
+ * --phantom
+ */
+ funcref = dlsym(RTLD_DEFAULT, "_kse_critical_enter");
+ if (funcref != NULL)
+ is_libc_r = 0;
+ else {
+ funcref = dlsym(RTLD_DEFAULT, "_thr_critical_enter");
+ if (funcref != NULL)
+ is_libc_r = 0;
+ }
+ }
+
+ if (is_libc_r == 0) {
+ /* Not a libc_r */
+ resultPid = fork();
+ } else {
+#endif /* __FreeBSD_version < 5 */
+ pthread_suspend_all_np();
+ resultPid = __sys_fork();
+ if (resultPid != 0)
+ /* leave child in single threading mode */
+ pthread_resume_all_np();
+#if (__FreeBSD_version < 5)
+ }
+#endif /* __FreeBSD_version < 5 */
+
+ return resultPid;
+}
+#endif /* __FreeBSD__ */
+
JNIEXPORT jint JNICALL
Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env,
jobject process,
@@ -335,8 +396,12 @@
if (path != NULL) {
cwd = (char *)JNU_GetStringPlatformChars(env, path, NULL);
}
-
+
+#if defined(__FreeBSD__)
+ resultPid = jdk_fork_wrapper();
+#else
resultPid = fork();
+#endif
if (resultPid < 0) {
char errmsg[128];

View File

@ -2,6 +2,7 @@ jdk%%JDK_VERSION%%/COPYRIGHT
jdk%%JDK_VERSION%%/LICENSE
jdk%%JDK_VERSION%%/README
jdk%%JDK_VERSION%%/README.html
jdk%%JDK_VERSION%%/src.zip
jdk%%JDK_VERSION%%/bin/ControlPanel
jdk%%JDK_VERSION%%/bin/HtmlConverter
jdk%%JDK_VERSION%%/bin/appletviewer

View File

@ -7,6 +7,7 @@
PORTNAME= jdk
PORTVERSION= ${JDK_VERSION}p${JDK_PATCHSET_VERSION}
PORTREVISION= 1
CATEGORIES= java devel
MASTER_SITES= # http://www.sun.com/software/java2/download.html
# http://www.eyesbeyond.com/freebsddom/java/jdk14.html
@ -211,8 +212,6 @@ post-build:
@# XXX make sure that SwingSet2/resources does not exists
@${RM} -rf ${JDKIMAGEDIR}/demo/jfc/SwingSet2/resources
@${RM} -rf ${JDKIMAGEDIR}/demo/plugin/jfc/SwingSet2/resources
@# This file serves no purpose (in case of port)
@${RM} -f ${JDKIMAGEDIR}/src.zip
.if !defined(NODEBUG)
pre-install:

View File

@ -0,0 +1,93 @@
$FreeBSD$
--- ../../j2se/src/solaris/native/java/lang/UNIXProcess_md.c.bsd.orig Wed Oct 29 12:22:58 2003
+++ ../../j2se/src/solaris/native/java/lang/UNIXProcess_md.c.bsd Wed Oct 29 12:23:33 2003
@@ -22,6 +22,12 @@
#include <errno.h>
#include <unistd.h>
+#if defined(__FreeBSD__)
+#include <dlfcn.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#endif
+
/* path in the environment */
static char **PATH = 0;
/* effective uid */
@@ -228,6 +234,61 @@
}
}
+#if defined(__FreeBSD__)
+
+extern pid_t __sys_fork(void);
+
+static pid_t
+jdk_fork_wrapper()
+{
+ pid_t resultPid;
+#if (__FreeBSD_version < 5)
+ static int is_libc_r = -1;
+ void *funcref;
+
+ if (is_libc_r == -1) {
+ is_libc_r = 1;
+
+ /*
+ * BSDNOTE: Check for loaded symbols.
+ *
+ * If "_thr_critical_enter" is found assume we are using 'libthr'.
+ * If _kse_critical_enter is found assume we are using 'libkse'.
+ * Otherwise we are using libc_r.
+ *
+ * If libc_r is loaded, use fork system call drectly to avoid
+ * problems with using protected pages.
+ *
+ * --phantom
+ */
+ funcref = dlsym(RTLD_DEFAULT, "_kse_critical_enter");
+ if (funcref != NULL)
+ is_libc_r = 0;
+ else {
+ funcref = dlsym(RTLD_DEFAULT, "_thr_critical_enter");
+ if (funcref != NULL)
+ is_libc_r = 0;
+ }
+ }
+
+ if (is_libc_r == 0) {
+ /* Not a libc_r */
+ resultPid = fork();
+ } else {
+#endif /* __FreeBSD_version < 5 */
+ pthread_suspend_all_np();
+ resultPid = __sys_fork();
+ if (resultPid != 0)
+ /* leave child in single threading mode */
+ pthread_resume_all_np();
+#if (__FreeBSD_version < 5)
+ }
+#endif /* __FreeBSD_version < 5 */
+
+ return resultPid;
+}
+#endif /* __FreeBSD__ */
+
JNIEXPORT jint JNICALL
Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env,
jobject process,
@@ -335,8 +396,12 @@
if (path != NULL) {
cwd = (char *)JNU_GetStringPlatformChars(env, path, NULL);
}
-
+
+#if defined(__FreeBSD__)
+ resultPid = jdk_fork_wrapper();
+#else
resultPid = fork();
+#endif
if (resultPid < 0) {
char errmsg[128];

View File

@ -2,6 +2,7 @@ jdk%%JDK_VERSION%%/COPYRIGHT
jdk%%JDK_VERSION%%/LICENSE
jdk%%JDK_VERSION%%/README
jdk%%JDK_VERSION%%/README.html
jdk%%JDK_VERSION%%/src.zip
jdk%%JDK_VERSION%%/bin/ControlPanel
jdk%%JDK_VERSION%%/bin/HtmlConverter
jdk%%JDK_VERSION%%/bin/appletviewer