private String[] tryToReadMaxRestarts(String[] commandLine) {
        List<String> args = new ArrayList<>();
        for (int i = 0; i < commandLine.length; i++) {
            String arg = commandLine[i];
            if (arg.equals("-maxRestarts")) {
                if (i == commandLine.length - 1) {
                    throw new IllegalArgumentException("Must specify an integer after \"-maxRestarts\"");
                }
                String restartNumString = commandLine[i + 1];
                try {
                    maxProcessRestarts = Integer.parseInt(restartNumString);
                } catch (NumberFormatException e) {
                    throw new IllegalArgumentException("Must specify an integer after \"-maxRestarts\" arg.");
                }
                i++;
            } else {
                args.add(arg);
            }
        }
        return args.toArray(new String[0]);
    }
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