
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

   public static void main(String[] args) throws Exception {

	System.out.println("Hello Java 9! This process PID is " + ProcessHandle.current().pid());

	ProcessBuilder builder = new ProcessBuilder("ls");
	builder.redirectErrorStream(true);

	Process childProcess = builder.start();

	try (BufferedReader in = new BufferedReader(new InputStreamReader(childProcess.getInputStream()))) {
		in.lines().forEach(System.out::println);
	}

	// define a function to call when the child process ends
	// and block until that function completes
	childProcess.onExit()
                    .whenComplete( Main::mainFinished )
                    .get();

   }

   public static void mainFinished(Process p, Throwable t) {
      System.out.println("Child process " + p.pid() + " finished.");
   }

}

@@ -168,22 +168,8 @@
 ln(%22
-Hello Java 9! 
 This
@@ -219,16 +219,85 @@
 .pid());
+%0A%09System.out.println(%22(We can only get the PID this way in Java 9)%22);
 %0A%0A%09Proce
@@ -916,16 +916,94 @@
 hed.%22);%0A
+      System.out.println(%22(Can only post-process like this in Java 9, too)%22);%0A
    %7D%0A%0A%7D%0A

update process demo