Date: Fri, 11 Oct 2002 12:57:35 +0200 (CEST) From: "Georg-W. Koltermann" <Georg.Koltermann@mscsoftware.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Georg.Koltermann@mscsoftware.com Subject: ports/43924: writing from JAVA to a pipe sometimes hangs Message-ID: <200210111057.g9BAvZxV003866@hunter.muc.macsch.com>
next in thread | raw e-mail | index | archive | help
>Number: 43924 >Category: ports >Synopsis: writing from JAVA to a pipe sometimes hangs >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 11 04:00:13 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Georg-W. Koltermann >Release: FreeBSD 4.6-RELEASE i386 >Organization: MSC.Software >Environment: System: FreeBSD hunter.muc.macsch.com 4.6-RELEASE FreeBSD 4.6-RELEASE #5: Sun Sep 22 22:13:46 CEST 2002 gwk@hunter.muc.macsch.com:/usr/obj/usr/src/sys/HUNTER i386 >Description: JAVA apparently has a problem writing to pipes. The attached program writes a bunch of zeros to the pipeline "| cat > somefile". With the FreeBSD native JDK 1.3.1 patcheset 6 it randomly hangs at various loop indices. The problem also hangs with the SUN Linux JDK 1.3.1 as long as the JDK runs with -classic. It also hangs on a Linux system with the Linux JDK 1.3.1 with -classic. So it seems there is a bug in the JDK itself. However, on any other platform than FreeBSD the JDK runs with a default of -hotspot, and with that setting the problem does not show up. On IRIX it even doesn't show up with the JDK 1.3.1 with green threads and no JIT, so there must be a way to fix it. May I ask that we try to fix this problem in the FreeBSD port, since on FreeBSD the alternative of using -hotspot are not available, or does not work reliably. >How-To-Repeat: ----------------test-case-----------snip------------- import java.io.*; public class PipeWrite { public static void usage() { System.err.println("Usage: PipeWrite outfile"); } public static void main(String argv[]) throws Exception { if (argv.length < 1) { usage(); return; } // String cmd = "/bin/sh -c 'cat >" + argv[0] + "'"; String cmd[] = { "/bin/sh", "-c", "cat >" + argv[0] }; writePipe(cmd); } private static void writePipe(String pipeCmd[]) throws Exception { Process p = Runtime.getRuntime().exec(pipeCmd); byte buffer[] = new byte[16384]; OutputStream pipe = p.getOutputStream(); InputStream stderr = p.getErrorStream(); try { for (int i = 0; i < 100; i++) { System.out.println("buffer " + i + "..."); pipe.write(buffer); System.out.println("ok"); // // The problem goes away when the following line // is uncommented: // Thread.sleep(1); } } finally { pipe.close(); System.out.println("rc=" + p.waitFor()); BufferedReader err = new BufferedReader(new InputStreamReader(stderr)); String line; while ((line = err.readLine()) != null) { System.err.println(line); } err.close(); } } } ----------------end-test-case-----------snip------------- >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210111057.g9BAvZxV003866>