code: public static void fork(String sjavacCmd, PortFile portFile, int poolsize, int keepalive)
              throws IOException, InterruptedException {
          List<String> cmd = new ArrayList<>();
          cmd.addAll(Arrays.asList(OptionHelper.unescapeCmdArg(sjavacCmd).split(" ")));
          cmd.add("--startserver:"
                + "portfile=" + portFile.getFilename()
                + ",poolsize=" + poolsize
                + ",keepalive="+ keepalive);
  
          Process serverProcess;
          Log.debug("Starting server. Command: " + String.join(" ", cmd));
          try {
              // If the cmd for some reason can't be executed (file is not found,
              // or is not executable for instance) this will throw an
              // IOException and p == null.
              serverProcess = new ProcessBuilder(cmd)
                      .redirectErrorStream(true)
                      .start();
          } catch (IOException ex) {
              // Message is typically something like:
              // Cannot run program "xyz": error=2, No such file or directory
              Log.error("Failed to create server process: " + ex.getMessage());
              Log.debug(ex);
              throw new IOException(ex);
          }
  
          // serverProcess != null at this point.
          try {
              // Throws an IOException if no valid values materialize
              portFile.waitForValidValues();
          } catch (IOException ex) {
              // Process was started, but server failed to initialize. This could
              // for instance be due to the JVM not finding the server class,
              // or the server running in to some exception early on.
              Log.error("Sjavac server failed to initialize: " + ex.getMessage());
              Log.error("Process output:");
              Reader serverStdoutStderr = new InputStreamReader(serverProcess.getInputStream());
              try (BufferedReader br = new BufferedReader(serverStdoutStderr)) {
                  br.lines().forEach(Log::error);
              }
              Log.error("<End of process output>");
              try {
                  Log.error("Process exit code: " + serverProcess.exitValue());
              } catch (IllegalThreadStateException e) {
                  // Server is presumably still running.
              }
              throw new IOException("Server failed to initialize: " + ex.getMessage(), ex);
          }
      }
docs: /*
  Fork a server process process and wait for server to come around