Date: Thu, 1 Jun 2000 09:36:33 +0930 (CST) From: Greg Lewis <glewis@trc.adelaide.edu.au> To: Volker Paepcke <scratchy@VULCAN.franken.de> Cc: freebsd-java@FreeBSD.ORG Subject: Re: Bug report for patchset 8 Message-ID: <200006010006.JAA21656@ares.trc.adelaide.edu.au> In-Reply-To: <200005231128.NAA86747@yavin.franken.de> from Volker Paepcke at "May 23, 2000 01:28:41 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Volker Paepcke wrote:
> And here comes the bug: all external programm execution doesn't work!
> e.g. compiling with jikes or running cvs commands. The external programm
> terminates but the IDE is waiting forever. I've written a small program
> that reproduces this problem:
>
> import java.io.*;
>
> public class ExecTest
> {
> public static void main(String args[])
> {
> try {
> Process proc = Runtime.getRuntime().exec(new String[] { "date" });
> proc.waitFor();
> } catch (Exception ex) {
> ex.printStackTrace();
> }
> }
> }
>
> the call to waitFor() never returns. With the JDK 1.1.8 and Blackdown's RC4
> the waitFor() call is returning immediatly. I'm running FreeBSD 4.0-Stable.
Hi Volker and all,
Attached is a patch which fixes this problem. It will be in patchset 9.
Thanks again to Volker for the bug report and simple example :).
--
Greg Lewis glewis@trc.adelaide.edu.au
Computing Officer +61 8 8303 5083
Teletraffic Research Centre
[-- Attachment #2 --]
Index: src/freebsd/native/java/lang/UNIXProcess_md.c
===================================================================
RCS file: /data/java/JDK2/javasrc/src/freebsd/native/java/lang/UNIXProcess_md.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- src/freebsd/native/java/lang/UNIXProcess_md.c 1999/10/11 18:46:30 1.2
+++ src/freebsd/native/java/lang/UNIXProcess_md.c 2000/05/31 15:46:04 1.3
@@ -166,8 +166,9 @@
JNIEXPORT void JNICALL
Java_java_lang_UNIXProcess_run(JNIEnv *env, jobject process)
{
-#ifdef __FreeBSD__ /*** XXX ***/
- char info[256];
+#ifdef __FreeBSD__
+ pid_t pid;
+ int status;
#else
siginfo_t info;
#endif
@@ -188,14 +189,14 @@
/* block this reaper thread until the child process exits */
#ifdef __FreeBSD__
-/* waitpid() is a wrapper, that does the "right thing" already */
- if (waitid(P_ALL, 0, &info, WEXITED) != 0) {
- continue;
- }
+ /* waitpid() is a wrapper, that does the "right thing" already */
+ pid = waitid(P_ALL, 0, &status, WEXITED);
#else
if (waitid(P_ALL, 0, &info, WEXITED) != 0 || info.si_pid == 0) {
continue;
}
+ pid = info.si_pid;
+ status = info.si_status;
#endif
(*env)->MonitorEnter(env, fork_wait_mon);
@@ -205,13 +206,8 @@
"java/lang/UNIXProcess",
"deadChild",
"(II)V",
-#ifdef __FreeBSD__ /*** XXX ***/
- 0,
- 0
-#else
- info.si_pid,
- info.si_status
-#endif
+ pid,
+ status
);
if ((*env)->ExceptionOccurred(env)) {
return;
Index: src/freebsd/hpi/green_threads/src/synch.c
===================================================================
RCS file: /data/java/JDK2/javasrc/src/freebsd/hpi/green_threads/src/synch.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- src/freebsd/hpi/green_threads/src/synch.c 1999/11/03 03:54:58 1.4
+++ src/freebsd/hpi/green_threads/src/synch.c 2000/05/31 15:41:06 1.5
@@ -170,7 +170,7 @@
#ifdef __FreeBSD__
pid_t fork1(void);
-int waitid(int, int, void *, int);
+pid_t waitid(int, int, int *, int);
#endif
/* For java.lang.Process */
@@ -179,17 +179,16 @@
extern int _waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options)
#else
-int waitid(int idtype, int id, void *infop, int options)
+pid_t waitid(int idtype, int id, int *status, int options)
#endif
{
sys_mon_t *mon = asyncMon(SYS_ASYNC_MON_CHILD);
#ifdef __FreeBSD__
- int status;
pid_t pid;
sysMonitorEnter(sysThreadSelf(), mon);
do {
- pid = waitpid(-1, &status, WNOHANG);
+ pid = waitpid(-1, status, WNOHANG);
if ((int)pid > 0 && !WIFSTOPPED(status))
break;
sysMonitorWait(sysThreadSelf(), mon, SYS_TIMEOUT_INFINITY);
@@ -202,7 +201,11 @@
}
#endif
sysMonitorExit(sysThreadSelf(), mon);
+#ifdef __FreeBSD__
+ return pid;
+#else
return 0;
+#endif
}
#ifndef __FreeBSD__
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006010006.JAA21656>
