ccs.utils
Class ProcessMonitor

java.lang.Object
  extended by ccs.utils.ProcessMonitor
All Implemented Interfaces:
java.lang.Runnable

public class ProcessMonitor
extends java.lang.Object
implements java.lang.Runnable

A ProcessMonitor monitors a running child Process object and transfers its stdout and stderr streams to System.out and System.err respectively. Without this, more "conversational" apps may block when the stream buffers get full (and you have no debugging diagnostics if something goes wrong).


Constructor Summary
ProcessMonitor(java.lang.Process proc)
          Create a new ProcessMonitor with a default catnap period.
ProcessMonitor(java.lang.Process proc, int catnap)
          Create a new ProcessMonitor.
 
Method Summary
 int getExitCode()
          Obtain the process' exit code.
 void run()
          Monitor the process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessMonitor

public ProcessMonitor(java.lang.Process proc)
Create a new ProcessMonitor with a default catnap period.

Parameters:
proc - The process to monitor.

ProcessMonitor

public ProcessMonitor(java.lang.Process proc,
                      int catnap)
Create a new ProcessMonitor.

Parameters:
proc - The process to monitor.
catnap - The time in ms to wait, when there is no output from the child process, before trying again.
Method Detail

run

public void run()
Monitor the process. This will block until the process has finished.

Specified by:
run in interface java.lang.Runnable

getExitCode

public int getExitCode()
                throws java.lang.IllegalThreadStateException
Obtain the process' exit code. This may or may not be meaningful

Throws:
java.lang.IllegalThreadStateException - If the process hasn't finished