< prev index next >

test/java/lang/ProcessHandle/JavaChild.java

Print this page
rev 12544 : 8131168: Refactor ProcessHandleImpl_*.c and add implememtation for AIX
Reviewed-by: rriggs, smarks

*** 66,77 **** * Create a JavaChild control instance that delegates to the spawned process. * {@link #sendAction} is used to send commands via the processes stdin. * {@link #forEachOutputLine} can be used to process output from the child * @param delegate the process to delegate and send commands to and get responses from */ ! private JavaChild(Process delegate) { ! this.delegate = delegate; // Initialize PrintWriter with autoflush (on println) inputWriter = new PrintWriter(delegate.getOutputStream(), true); outputReader = new BufferedReader(new InputStreamReader(delegate.getInputStream())); } --- 66,78 ---- * Create a JavaChild control instance that delegates to the spawned process. * {@link #sendAction} is used to send commands via the processes stdin. * {@link #forEachOutputLine} can be used to process output from the child * @param delegate the process to delegate and send commands to and get responses from */ ! private JavaChild(ProcessBuilder pb) throws IOException { ! allArgs = pb.command(); ! delegate = pb.start(); // Initialize PrintWriter with autoflush (on println) inputWriter = new PrintWriter(delegate.getOutputStream(), true); outputReader = new BufferedReader(new InputStreamReader(delegate.getInputStream())); }
*** 117,126 **** --- 118,131 ---- @Override public String toString() { return "delegate: " + delegate.toString(); } + public List<String> getArgs() { + return allArgs; + } + public CompletableFuture<JavaChild> onJavaChildExit() { return onExit().thenApply(ph -> this); } /**
*** 185,195 **** for (int i = 0; i < args.length; i++) { stringArgs[i] = args[i].toString(); } ProcessBuilder pb = build(stringArgs); pb.redirectError(ProcessBuilder.Redirect.INHERIT); ! return new JavaChild(pb.start()); } /** * Spawn a JavaChild with the provided arguments. * Sets the process to inherit the I/O channels. --- 190,200 ---- for (int i = 0; i < args.length; i++) { stringArgs[i] = args[i].toString(); } ProcessBuilder pb = build(stringArgs); pb.redirectError(ProcessBuilder.Redirect.INHERIT); ! return new JavaChild(pb); } /** * Spawn a JavaChild with the provided arguments. * Sets the process to inherit the I/O channels.
*** 234,243 **** --- 239,251 ---- "-XX:+DisplayVMOutputToStderr", "-Dtest.jdk=" + javaHome, "-classpath", absolutifyPath(classpath), "JavaChild"); + // Will hold the complete list of arguments which was given to Processbuilder.command() + private List<String> allArgs; + private static String absolutifyPath(String path) { StringBuilder sb = new StringBuilder(); for (String file : path.split(File.pathSeparator)) { if (sb.length() != 0) sb.append(File.pathSeparator);
< prev index next >