test/java/lang/ProcessBuilder/Basic.java
Print this page
@@ -296,15 +296,22 @@
System.exit(5);
if (! new String(buf,0,n).equals(expected))
System.exit(5);
System.err.print("standard error");
System.out.print("standard output");
- } else if (action.equals("testInheritIO")) {
+ } else if (action.equals("testInheritIO")
+ || action.equals("testRedirectInherit")) {
List<String> childArgs = new ArrayList<String>(javaChildArgs);
childArgs.add("testIO");
ProcessBuilder pb = new ProcessBuilder(childArgs);
+ if (action.equals("testInheritIO")) {
pb.inheritIO();
+ } else {
+ pb.redirectInput(Redirect.INHERIT)
+ .redirectOutput(Redirect.INHERIT)
+ .redirectError(Redirect.INHERIT);
+ }
ProcessResults r = run(pb);
if (! r.out().equals(""))
System.exit(7);
if (! r.err().equals(""))
System.exit(8);
@@ -1017,14 +1024,14 @@
//----------------------------------------------------------------
// Testing INHERIT is harder.
// Note that this requires __FOUR__ nested JVMs involved in one test,
// if you count the harness JVM.
//----------------------------------------------------------------
- {
+ for (String testName : new String[] { "testInheritIO", "testRedirectInherit" } ) {
redirectIO(pb, PIPE, PIPE, PIPE);
List<String> command = pb.command();
- command.set(command.size() - 1, "testInheritIO");
+ command.set(command.size() - 1, testName);
Process p = pb.start();
new PrintStream(p.getOutputStream()).print("standard input");
p.getOutputStream().close();
ProcessResults r = run(p);
equal(r.exitValue(), 0);