private synchronized void closeUnusedProcessHandle()

in src/com/pty4j/windows/winpty/WinPty.java [252:264]


  private synchronized void closeUnusedProcessHandle() {
    // Keep the process handle open until both conditions are met:
    //  1. The process has exited.
    //  2. We have disconnected from the agent, by closing the winpty_t
    //     object.
    // As long as the process handle is open, Windows will not reuse the child
    // process' PID.
    // https://blogs.msdn.microsoft.com/oldnewthing/20110107-00/?p=11803
    if (myClosed && myChildExited && myProcess != null) {
      Kernel32.INSTANCE.CloseHandle(myProcess);
      myProcess = null;
    }
  }