// To be called exactly twice by the parent process static <T> T rendezvousParent(Process p, Callable<T> callable) throws Throwable { p.getInputStream().read(); T result = callable.call(); OutputStream os = p.getOutputStream(); os.write((byte) '\n'); os.flush(); return result; }
static String outputOf(final Process p) { try { Future<String> outputFuture = futureOutputOf(p.getInputStream()); Future<String> errorFuture = futureOutputOf(p.getErrorStream()); final String output = outputFuture.get(); final String error = errorFuture.get(); // Check for successful process completion equal(error, ""); equal(p.waitFor(), 0); equal(p.exitValue(), 0); return output; } catch (Throwable t) { unexpected(t); throw new Error(t); } }