Name: dbT83986 Date: 02/09/99
When a process (a.exe) is executed, if the process
writes more than 488 bytes of data on it's STDOUT
and we then call the waitFor( ) method of the Process
class to wait for completion of a.exe , both
the processes hangs. Strange enough , if in Java
we don't wait for process completion , (mask
call to waitFor( ) method), then the execution is
succeeded. Or if, in a.exe, we only write 488
bytes or less then the waitFor() method works without
hanging .
To reproduce the problem
Step 1:
Compile the follwing file a.c into a binary a.exe :
//////
#include<stdio.h>
main()
{
char buf[500];
/*
// Works
memset(buf,'\0',500);
memset(buf,'p',488);
fprintf(stdout,"%s",buf);
*/
// dosen't Works
memset(buf,'\0',500);
memset(buf,'p',489);
fprintf(stdout,"%s",buf);
}
/////////////
Step 2:
Compile the following Java program (within a directory test) execute it.
///////////
package test;
import java.io.*;
import java.lang.*;
/**
* Class for testing
*/
public class Test {
public static void main(String[]args) {
InputStream input;
BufferedReader buf;
String str;
Process process;
Runtime runtimeContext;
try {
runtimeContext = Runtime.getRuntime();
process = runtimeContext.exec("a");
process.waitFor();
input = process.getInputStream();
buf = new BufferedReader(new InputStreamReader(input));
while((str = buf.readLine()) != null) {
System.out.println(str);
}
}
catch(IOException e) {}
catch(InterruptedException e) {};
}
}
/////////////////////////
Step 3:
Run java test.Test to execute Java program and exec
a.exe through JVM.
(Review ID: 40393)
======================================================================
- relates to
-
JDK-4368399 JDI: -verbose option passed to debugger launcher fails and hangs vm
- Closed