Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 9430

Summary: Process.getInputStream().ready() never succeeds
Product: [Eclipse Project] JDT Reporter: Randy Coulman <RCoulman>
Component: DebugAssignee: Darin Wright <darin.eclipse>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P1 CC: darin.eclipse
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
error dialog none

Description Randy Coulman CLA 2002-02-11 16:55:19 EST
We have an application that launches a command-line process using 
Runtime.exec(), then uses Process.getInputStream() to read what is output on the 
console.  It has a loop waiting for the stream to be ready() before actually 
trying to read any input.  When running this application from the command line 
or from Kawa (our hopefully soon-to-be-previous Java development environment), 
this works fine.  However, when running (or debugging) under Eclipse, the call 
to ready() never succeeds.

This is done during the startup of our application, so we are completely unable 
to run or debug using Eclipse because of this problem.

Here is a small, self-contained example program that illustrates the problem.  
If you run or debug this in Eclipse, it will hang on the while(!in.ready()) 
loop.  If you run from the command line, using the class file compiled by 
Eclipse, the program runs to completion.

I am using Eclipse 2.0 latest stable build (01/25/2002) and Sun's JDK 1.3.0.

import java.io.*;

public class BugTest
{
	public BugTest()
	{
		super();
	}

	public static void main(String[] args)
	{
		try
		{
			System.out.println("Running command...");
			Process p = (Runtime.getRuntime()).exec("command.com /C 
ipconfig /all");
			BufferedReader in =
				new BufferedReader(new 
InputStreamReader(p.getInputStream()));
			while (!in.ready())
			{
			}
			System.out.println("Will never get here.");

			while (in.ready())
			{
				System.out.println(in.readLine());
			}
			p.destroy();
		}
		catch (Exception e)
		{
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
	}
}
Comment 1 Philipe Mulet CLA 2002-02-12 06:28:20 EST
Compiler is innocent here, launching issue.
Comment 2 Darin Wright CLA 2002-02-12 09:42:32 EST
Running from a DOS console, using JDK1.4rc, the program does run either. Using 
1.3.1_01, the program runs from a console, but not within Eclipse.
Comment 3 Darin Wright CLA 2002-02-12 09:53:06 EST
Appears to be an issue with the command being run. When I run "ping 127.1.1.0", 
I can get output with no trouble. When I use "command.com /C ipconfig /all", I 
do not get output.

When running "command.com /C ipconfig /all" on 1.4rc, eventually a error dialog 
appears. See attachment.
Comment 4 Darin Wright CLA 2002-02-12 09:56:33 EST
Created attachment 348 [details]
error dialog
Comment 5 Randy Coulman CLA 2002-02-12 10:45:17 EST
Some more experimentation (triggered by the attached error message) shows that I 
can use cmd.exe in the command line instead of command.com and everything works 
fine.  Going further, I find I don't even need the cmd.exe /C at all.  I can 
just use ipconfig /all as the command line and get what I need.

Given these results, this issue is no longer a blocker for us.
Comment 6 Darin Wright CLA 2002-02-12 10:47:05 EST
A command issue. Closing.