Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2019432 | 1.3.0 | Anand Palaniswamy | P3 | Resolved | Fixed | beta |
JDK-2019431 | 1.2.2_002 | Anand Palaniswamy | P3 | Resolved | Fixed | b02 |
Name: eyC74480 Date: 03/10/98
java.lang.UNIXProcess always waits for 1 second.
(in both JDK1.1.x and JDK1.2).
ProcessInputStream within UNIXProcess never flushes
any read data.
So user of UNIXProcess has to wait for timeout(1 second).
This is default manner of java.io.PipedInputStream#receive(int).
Following is a patch for UNIXProcess.java.
*** UNIXProcess.java.orig Tue Jan 13 11:26:04 1998
--- UNIXProcess.java Tue Mar 10 14:51:45 1998
***************
*** 326,331 ****
--- 326,332 ----
if ((nread = ins.read(buf)) < 0)
break;
outs.write(buf, 0, nread);
+ outs.flush();
} catch (IOException e) {
break;
}
if you do this patch,
it works well.
!qv
Following program is a test program.
If you do the program,
you see that output of echo is always waiting for 1 sec.
Once you do above patch,
you will see the output is no longer waiting.
import java.io.*;
public class UNIXProcessTest {
public static void main(String[] args) {
try {
String[] commandArray = { "echo.pl" };
String[] inputStrings = { "abc", "def", "ghi" };
Process process = Runtime.getRuntime().exec(commandArray);
DataInputStream in
= new DataInputStream(process.getInputStream());
PrintStream out
= new PrintStream(process.getOutputStream());
int i = 0;
int j = 0;
while (i < 10) {
System.out.println("sending : "+inputStrings[j]);
System.out.flush();
out.println(inputStrings[j]);
out.flush();
String line = in.readLine();
System.out.println("received : "+line);
System.out.flush();
j++;
if (j >= inputStrings.length) {
j = 0;
i++;
}
}
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
(Review ID: 26299)
======================================================================
- backported by
-
JDK-2019431 (process) java.lang.UNIXProcess always waits for 1 second.
-
- Resolved
-
-
JDK-2019432 (process) java.lang.UNIXProcess always waits for 1 second.
-
- Resolved
-
- duplicates
-
JDK-4250595 java performance issue on Solaris.
-
- Closed
-
-
JDK-4251284 Solaris pipe-io of child process is very slow
-
- Closed
-