Exemple #1
0
 /**
  * Waits until the process is terminated or the timeout is elapsed.
  *
  * @return The exit code of the process
  */
 public int waitFor() {
   int exitCode = -1;
   if (process != null) {
     try {
       exitCode = process.waitFor();
       logger.debug("Closing errorStream...");
       errorStream.close();
       logger.debug("Closing outputStream...");
       outputStream.close();
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     ProcessTimer.removeTimer(timer);
     logger.debug("TProcess ended: exitCode = " + exitCode);
   } else {
     ErrorsAndWarnings.addError("Cannot call waitFor() on a null TProcess");
   }
   return exitCode;
 }
Exemple #2
0
 /** Destroys the process */
 public void stop() {
   ProcessTimer.removeTimer(timer);
   try {
     Thread.sleep(StreamListener.PRINTING_PERIOD_IN_MILLIS);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   if (errorStream != null) {
     logger.debug("Closing errorStream...");
     errorStream.close();
   }
   if (outputStream != null) {
     logger.debug("Closing outputStream...");
     outputStream.close();
   }
   if (process != null) {
     logger.debug("destroying TProcess...");
     process.destroy();
     logger.debug("TProcess destroyed");
   }
 }