void () { try { myProcess.getOutputStream().close(); } catch (IOException e) { // The process may have already terminated, but some data has not yet been written to its standard input. // For example, `com.intellij.execution.process.ProcessServiceImpl.sendWinProcessCtrlC(int, OutputStream)` // tries to terminate a process with `GenerateConsoleCtrlEvent(CTRL_C_EVENT)` and then writes `-1` to process's input to // unblock ReadConsoleW/ReadFile. // In this case, `close` will fail, because of close -> flush -> write, and 'write' cannot be performed // on a stream of the terminated process. if (myProcess.isAlive()) { LOG.warn("Cannot close stdin of '" + getCommandLine() + "'", e); } } try { myProcess.getInputStream().close(); } catch (IOException e) { if (myProcess.isAlive()) { LOG.warn("Cannot close stdout of '" + getCommandLine() + "'", e); } } try { myProcess.getErrorStream().close(); } catch (IOException e) { if (myProcess.isAlive()) { LOG.warn("Cannot close stderr of '" + getCommandLine() + "'", e); } } }