JDK-4098442 : Process.waitFor() fails to return
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.1.5
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1997-12-10
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2beta4Fixed
Related Reports
Relates :  
Description

Name: rm29839			Date: 12/10/97


Try this little bit of code on a WinNT box - the process.waitFor() call fails
to ever return. Works fine on HP/Sun/Linux JDK running 1.1.3.

String command = "C:/dev/jdk/bin/java";
System.out.println("---> Executing "+command);
Process process = Runtime.getRuntime().exec(command);
System.out.println("---> Waiting for completion of waitFor()");
process.waitFor();
System.out.println("---> waitFor() completed");

The waitFor() never returns - fails for all applications

import java.io.*;
public class Test {

  public static void main (String[] args){
    try{
    String command = "e:\win32\bin\java";
 //change this to match where your java lives
    System.out.println("--->Executing " + command);
    Process process = Runtime.getRuntime().exec(command);
    System.out.println("--->Waiting for completion of " + command);
    process.waitFor();
    System.out.println("--->Done Waiting!");
  }catch(IOException e){}catch (InterruptedException e){}

  }
}

This works fine under 1.1.5 on Solaris, but on win32
(Review ID: 21666)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

WORK AROUND Name: rm29839 Date: 12/10/97 There isn't that I know of. ======================================================================
11-06-2004

SUGGESTED FIX This is the behavior from the original design. Not going to fix it. More javadoc will help users with using the related API. ###@###.### 1998-02-13
13-02-1998

EVALUATION This is caused by pipe overflow. By default, the stdout and stderr from child process (java.exe in this case) will be redirected to parent process. If the parent process does not read the pipe, the child process will block when pipe is full. If we change the command in the Test.java to "c:\win32\bin\java a", the test will be OK. Because the error message will be "Can't find class a", which is too short to make the pipe full. Interesting. ###@###.### 1998-02-09
09-02-1998