# Class: com.pnfsoftware.jeb.util.concurrent.ProcessExec

A helpful class to safely execute short commands, in a blocking or non\-blocking way with or without a timeout, and retrieve the exit code and generated output\(s\) as byte arrays. 

 A lower\-level alternative that offers access to the streams \(including stdin\) is [ProcessWrapper](ProcessWrapper).

## Constructor: ProcessExec

Description: Create an object that will execute commands in blocking mode, without timeout.

## Constructor: ProcessExec
- parameter: `timeoutMs`, type: `long`
- parameter: `redirectErrToOut`, type: `boolean`

Description: Create an object that will execute commands.
parameter: timeoutMs: timeout for the command execution, in milliseconds:            
            
- zero: blocking, without timeout
-             
- positive value: blocking, and target will be killed when timeout has            elapsed
-             
- negative value: non\-blocking, [execute](#execute(String...)) returns true            immediately; subsequent calls to [#getOutput()](#getOutput()) return null
-
parameter: redirectErrToOut: if true, the error stream will be redirected to the output stream;            this flag is disregarded if the timeout is negative

## Method: execute
- parameter: `cmdlist`, type: `java.util.Collection<java.lang.String>`
- return type: `boolean`

Description: Execute a command. The method may block, depending on the timeout value provided to the constructor.
parameter: cmdlist: the command tokens \(command and arguments\), eg:            `["ls", "-l", "*.java"]`
return: true in non\-blocking mode or if execution completed, false otherwise

## Method: execute
- parameter: `cmdarray`, type: `java.lang.String[]`
- return type: `boolean`

Description: Execute a command. The method may block, depending on the timeout value provided to the constructor.
parameter: cmdarray: the command tokens \(command and arguments\), eg:            `["ls", "-l", "*.java"]`
return: true in non\-blocking mode or if execution completed, false otherwise

## Method: getError
- return type: `byte[]`

Description: Retrieve the command execution's error bytes, if execution completed. Never available in non\-blocking mode.
return: the bytes or null

## Method: getExitValue
- return type: `java.lang.Integer`

Description: Retrieve the command execution's exit value, if execution completed. Never available in non\-blocking mode.
return: the exit value or null

## Method: getOutput
- return type: `byte[]`

Description: Retrieve the command execution's output bytes, if execution completed. Never available in non\-blocking mode.
return: the bytes or null

