01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc;
05:
06: /**
07: * This is for monitoring a process where something else is draining the output and
08: * error streams, such as a ProcessWaiter or a ProcessOutputView.
09: */
10:
11: public class ProcessMonitor extends Thread {
12: private Process m_process;
13: private ProcessTerminationListener m_terminationListener;
14:
15: public ProcessMonitor(Process process,
16: ProcessTerminationListener terminationListener) {
17: super ();
18:
19: m_process = process;
20: m_terminationListener = terminationListener;
21:
22: start();
23: }
24:
25: public void run() {
26: while (true) {
27: try {
28: m_process.waitFor();
29: m_terminationListener.processTerminated(m_process
30: .exitValue());
31: return;
32: } catch (InterruptedException ie) {/**/
33: }
34: }
35: }
36: }
|