@Override
        public void run() {
            try {
                while (true) {
                    Thread.sleep(500);
                    if (userInterrupted) {
                        writer.write(String.format(Locale.ENGLISH, "Ave atque vale!%n"));
                        writer.flush();
                    }
                }
            } catch (IOException e) {
                //swallow
            } catch (InterruptedException e) {
                //job is done, ok
            }
        }
Class that writes to the forked process
to force an interrupt in the forked process.
tika-batch/src/main/java/org/apache/tika/batch/BatchProcessDriverCLI.java