1 19 20 package com.sslexplorer.applications.server; 21 import java.io.OutputStream ; 22 23 public class ProcessMonitor { 24 25 String name; 26 Process process; 27 28 IOStreamConnector stdout; 29 IOStreamConnector stderr; 30 31 public ProcessMonitor(String name, 32 Process process) { 33 34 this.process = process; 35 this.name = name; 36 } 37 38 39 public String getName() { 40 return name; 41 } 42 43 54 public int watch(OutputStream out, 55 OutputStream err) 56 throws InterruptedException { 57 58 stdout = new IOStreamConnector(); 59 stdout.connect(process.getInputStream(), out); 60 61 stderr = new IOStreamConnector(); 62 stderr.connect(process.getErrorStream(), err); 63 64 return process.waitFor(); 65 } 66 67 70 public void kill() { 71 process.destroy(); 72 } 73 74 75 76 77 78 } 79 | Popular Tags |