void (boolean await) { var processHandler = myProcessHandler; if (processHandler == null || processHandler.isProcessTerminated()) { myProcessHandler = null; return; } try { writeLine(EXIT_COMMAND); } catch (IOException ignore) { } if (await) { var timeout = TimeUnit.MILLISECONDS.toNanos(EXIT_TIMEOUT_MS) + System.nanoTime(); while (!processHandler.isProcessTerminated()) { if (System.nanoTime() > timeout) { LOG.warn("File watcher is still alive, doing a force quit."); processHandler.destroyProcess(); break; } processHandler.waitFor(10); } myProcessHandler = null; } }