com.isti.util
Class ProcessUtilFns

java.lang.Object
  extended bycom.isti.util.ProcessUtilFns

public class ProcessUtilFns
extends java.lang.Object

Class ProcessUtilFns contains various static utility methods for working with processes.


Constructor Summary
protected ProcessUtilFns()
           
 
Method Summary
static java.lang.Process exec(java.lang.String command)
          Executes the specified string command in a separate process.
static java.lang.Process exec(java.lang.String command, java.io.PrintStream stderrPrintStream, java.io.PrintStream stdoutPrintStream)
          Executes the specified string command in a separate process.
static java.lang.Integer exitValue(java.lang.Process p)
          Returns the exit value for the specified process.
static java.lang.Integer waitFor(java.lang.Process p)
          causes the current thread to wait, if necessary, until the specified process has terminated.
static java.lang.Integer waitFor(java.lang.Process p, long millis)
          causes the current thread to wait, if necessary, until the specified process has terminated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessUtilFns

protected ProcessUtilFns()
Method Detail

exec

public static java.lang.Process exec(java.lang.String command)
                              throws java.io.IOException
Executes the specified string command in a separate process.

Warning: It is possible that the program will deadlock if the process generates enough output to overflow the system.

Parameters:
command - a specified system command.
Returns:
a Process object for managing the process.
Throws:
java.lang.SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a process.
java.io.IOException - if an I/O error occurs
See Also:

The command argument is parsed into tokens and then executed as a command in a separate process. The token parsing is done by a {@link java.util.StringTokenizer} created by the call:

 new StringTokenizer(command)
 
with no further modifications of the character categories. This method has exactly the same effect as exec(command, null).
, Runtime.exec(java.lang.String, java.lang.String[]), SecurityManager.checkExec(java.lang.String)

exec

public static java.lang.Process exec(java.lang.String command,
                                     java.io.PrintStream stderrPrintStream,
                                     java.io.PrintStream stdoutPrintStream)
                              throws java.io.IOException
Executes the specified string command in a separate process.

The command argument is parsed into tokens and then executed as a command in a separate process. The token parsing is done by a StringTokenizer created by the call:

 new StringTokenizer(command)
 
with no further modifications of the character categories. This method has exactly the same effect as exec(command, null).

Parameters:
command - a specified system command.
stderrPrintStream - "standard" error output print stream or null if the "standard" error output is to be ignored.
stdoutPrintStream - "standard" output print stream or null if the "standard" output is to be ignored.
Returns:
a Process object for managing the process.
Throws:
java.lang.SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a process.
java.io.IOException - if an I/O error occurs
See Also:
Runtime.exec(java.lang.String, java.lang.String[]), SecurityManager.checkExec(java.lang.String)

exitValue

public static java.lang.Integer exitValue(java.lang.Process p)
Returns the exit value for the specified process.

Parameters:
p - the process.
Returns:
the exit value of the process represented by this Process object or null if the process has not yet terminated. By convention, 0 indicates normal termination.

waitFor

public static java.lang.Integer waitFor(java.lang.Process p)
                                 throws java.lang.InterruptedException
causes the current thread to wait, if necessary, until the specified process has terminated. This method returns immediately if the process has already terminated. If the process has not yet terminated, the calling thread will be blocked until the process exits.

Parameters:
p - the process.
Returns:
the exit value of the process. By convention, 0 indicates normal termination.
Throws:
java.lang.InterruptedException - if the current thread is interrupted by another thread while it is waiting, then the wait is ended and an InterruptedException is thrown.

waitFor

public static java.lang.Integer waitFor(java.lang.Process p,
                                        long millis)
                                 throws java.lang.InterruptedException
causes the current thread to wait, if necessary, until the specified process has terminated. This method returns immediately if the process has already terminated. If the process has not yet terminated, the calling thread will be blocked until the process exits or the wait time has been reached. If the wait time is reached the process will be terminated.

Parameters:
p - the process.
millis - Waits at most millis milliseconds for this thread to exit. A timeout of 0 means to wait forever.
Returns:
the exit value of the process or null if wait time was reached. By convention, 0 indicates normal termination.
Throws:
java.lang.InterruptedException - if the current thread is interrupted by another thread while it is waiting, then the wait is ended and an InterruptedException is thrown.