private void shutdownDriverNow() {
        if (process != null) {
            for (int i = 0; i < 60; i++) {

                LOG.trace("trying to shut down: {}", i);
                try {
                    int exit = process.exitValue();
                    LOG.trace("trying to stop: {}", exit);
                    stop();
                    interruptWatcherThread.interrupt();
                    return;
                } catch (IllegalThreadStateException e) {
                    //hasn't exited
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    //swallow
                }
            }
            LOG.error("Process didn't stop after 60 seconds after shutdown. " + "I am forcefully terminating it.");
        }
        interruptWatcherThread.interrupt();
    }
This relies on an special exit values of 254 (do not restart),
0 ended correctly, 253 ended with exception (do restart)
tika-batch/src/main/java/org/apache/tika/batch/BatchProcessDriverCLI.java