public void destroyProcess()

in src/main/java/org/apache/sling/testing/serversetup/jarexec/ShutdownHookSingleProcessDestroyer.java [78:116]


   public void destroyProcess(boolean waitForIt) {
       Process toDestroy = null;
       synchronized (this) {
           toDestroy = process;
           process = null;
       }
       
       if(toDestroy == null) {
           return;
       }
       
       toDestroy.destroy();
       
       if(waitForIt) {
           log.info("Waiting for destroyed process {} to exit (timeout={} seconds)", processInfo, timeoutSeconds);
           final Thread mainThread = Thread.currentThread();
           final Timer t = new Timer(true);
           final TimerTask task = new TimerTask() {
                @Override
                public void run() {
                    mainThread.interrupt();
                }
           };
           t.schedule(task, timeoutSeconds * 1000L);
           try {
               toDestroy.waitFor();
               try {
                   final int exit = toDestroy.exitValue();
                   log.info("Process {} ended with exit code {}", processInfo, exit);
               } catch(IllegalStateException ise) {
                   log.error("Failed to destroy process " + processInfo);
               }
           } catch (InterruptedException e) {
               log.error("Timeout waiting for process " + processInfo + " to exit");
            } finally {
                t.cancel();
            }
       }
   }