If earlier exec() call fails (IOException), subsequent exec() call never returns.
Test Scenario:
1. Exec1() generates IO exception (as expected).
2. When Exec2() is called, control never returns back (program hangs).
This happens on Linux (red hat linux 6.2). Works OK on Solaris and Windows.
(build 1.4.0beta-b40)
// ------------------- Test.java -------------------
class Test {
public static void main(String[] args) {
Test t = new Test();
t.Exec1(); // should generate IO exception
t.Exec2();
}
void Exec1() {
try {
String cmd ;
cmd = "invalid";
Process process = Runtime.getRuntime().exec(cmd);
} catch (Exception e) {
e.printStackTrace();
}
}
void Exec2() {
try {
String cmd ;
cmd = "ls";
Process process = Runtime.getRuntime().exec(cmd);
InputStream in = process.getInputStream();
DataInputStream din = new DataInputStream(in);
BufferedReader br
= new BufferedReader(new InputStreamReader(in));
String s;
while ((s = br.readLine()) != null) {
System.out.println(s);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
// --------------------------------------
Test Scenario:
1. Exec1() generates IO exception (as expected).
2. When Exec2() is called, control never returns back (program hangs).
This happens on Linux (red hat linux 6.2). Works OK on Solaris and Windows.
(build 1.4.0beta-b40)
// ------------------- Test.java -------------------
class Test {
public static void main(String[] args) {
Test t = new Test();
t.Exec1(); // should generate IO exception
t.Exec2();
}
void Exec1() {
try {
String cmd ;
cmd = "invalid";
Process process = Runtime.getRuntime().exec(cmd);
} catch (Exception e) {
e.printStackTrace();
}
}
void Exec2() {
try {
String cmd ;
cmd = "ls";
Process process = Runtime.getRuntime().exec(cmd);
InputStream in = process.getInputStream();
DataInputStream din = new DataInputStream(in);
BufferedReader br
= new BufferedReader(new InputStreamReader(in));
String s;
while ((s = br.readLine()) != null) {
System.out.println(s);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
// --------------------------------------
- duplicates
-
JDK-4393293 It's impossible to run external process (execution) in Forte4J with LadyBird.
-
- Closed
-