test/java/lang/Runtime/exec/StreamsSurviveDestroy.java
Print this page
*** 28,38 ****
*/
import java.io.*;
import java.util.concurrent.*;
-
public class StreamsSurviveDestroy {
private static class Copier extends Thread {
String name;
--- 28,37 ----
*** 100,110 ****
static void test() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("test");
! Process p = Runtime.getRuntime().exec("/bin/cat");
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
false, false, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
false, false, latch);
latch.await(); // Wait till both Copiers about to read
--- 99,109 ----
static void test() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("test");
! Process p = Runtime.getRuntime().exec(UnixCommands.cat());
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
false, false, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
false, false, latch);
latch.await(); // Wait till both Copiers about to read
*** 120,130 ****
static void testCloseBeforeDestroy() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testCloseBeforeDestroy");
! Process p = Runtime.getRuntime().exec("/bin/cat");
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
true, false, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
true, false, latch);
latch.await(); // Wait till both Copiers about to read
--- 119,129 ----
static void testCloseBeforeDestroy() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testCloseBeforeDestroy");
! Process p = Runtime.getRuntime().exec(UnixCommands.cat());
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
true, false, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
true, false, latch);
latch.await(); // Wait till both Copiers about to read
*** 141,151 ****
}
static void testCloseAfterDestroy() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testCloseAfterDestroy");
! Process p = Runtime.getRuntime().exec("/bin/cat");
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
true, false,latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
true, false, latch);
--- 140,150 ----
}
static void testCloseAfterDestroy() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testCloseAfterDestroy");
! Process p = Runtime.getRuntime().exec(UnixCommands.cat());
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
true, false,latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
true, false, latch);
*** 163,173 ****
}
static void testInterrupt() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testInterrupt");
! Process p = Runtime.getRuntime().exec("/bin/cat");
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
false, true, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
false, true, latch);
latch.await(); // Wait till both Copiers about to read
--- 162,172 ----
}
static void testInterrupt() throws Exception {
CountDownLatch latch = new CountDownLatch(2);
System.err.println("testInterrupt");
! Process p = Runtime.getRuntime().exec(UnixCommands.cat());
Copier cp1 = new Copier("out", p.getInputStream(), System.err,
false, true, latch);
Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
false, true, latch);
latch.await(); // Wait till both Copiers about to read
*** 186,197 ****
public static void main(String[] args) throws Exception {
// Applies only to Solaris; Linux and Windows
// behave a little differently
! if (!System.getProperty("os.name").equals("SunOS"))
return;
test();
testCloseBeforeDestroy();
testCloseAfterDestroy();
testInterrupt();
--- 185,198 ----
public static void main(String[] args) throws Exception {
// Applies only to Solaris; Linux and Windows
// behave a little differently
! if (!System.getProperty("os.name").equals("SunOS")) {
! System.err.println("For SunOS only");
return;
+ }
test();
testCloseBeforeDestroy();
testCloseAfterDestroy();
testInterrupt();