And here comes the test program.
import java.io.*;
/**
* This program demonstrates bug in gcj Runtime.exec().
*
* @author Jari Juslin, zds@iki.fi
*
* @version $Revision$
*/
public class GcjExecBugDemo {
/* **************************************************************** */
void run() {
Process uptimeProcess;
Reader stdoutReader;
while (true) {
try {
uptimeProcess = Runtime.getRuntime().exec("uptime");
// Just to make sure that bug is not in not opening
// input to process.
uptimeProcess.getOutputStream().close();
stdoutReader = new InputStreamReader(uptimeProcess.getInputStream());
while (stdoutReader.read() != -1)
;
stdoutReader.close();
uptimeProcess.destroy();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
System.out.println("IOException: " +
e.getMessage());
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
}
/* **************************************************************** */
public static void main(String[] args) {
GcjExecBugDemo gcjExecBugDemo;
gcjExecBugDemo = new GcjExecBugDemo();
gcjExecBugDemo.run();
}
}
Attachment:
signature.asc
Description: OpenPGP digital signature