From owner-freebsd-java Wed May 31 17: 6:54 2000 Delivered-To: freebsd-java@freebsd.org Received: from ares.trc.adelaide.edu.au (ares.trc.adelaide.edu.au [129.127.246.5]) by hub.freebsd.org (Postfix) with ESMTP id B72C937B759 for ; Wed, 31 May 2000 17:06:46 -0700 (PDT) (envelope-from glewis@ares.trc.adelaide.edu.au) Received: (from glewis@localhost) by ares.trc.adelaide.edu.au (8.9.3/8.9.3) id JAA21656; Thu, 1 Jun 2000 09:36:33 +0930 (CST) (envelope-from glewis) From: Greg Lewis Message-Id: <200006010006.JAA21656@ares.trc.adelaide.edu.au> Subject: Re: Bug report for patchset 8 In-Reply-To: <200005231128.NAA86747@yavin.franken.de> from Volker Paepcke at "May 23, 2000 01:28:41 pm" To: Volker Paepcke Date: Thu, 1 Jun 2000 09:36:33 +0930 (CST) Cc: freebsd-java@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL70 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM959817993-21639-0_ Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --ELM959817993-21639-0_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 --ELM959817993-21639-0_ Content-Type: text/plain; charset=US-ASCII Content-Disposition: attachment; filename=wait.diff Content-Description: wait.diff Content-Transfer-Encoding: 7bit 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__ --ELM959817993-21639-0_-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message