Process Class Reference

The Process JavaScript class. Used to launch an external process. More...

Public Slots

int launch ()
 Launch process. More...
 
int launchAndDetach ()
 Launch process and detach it from application. More...
 
String commandLine () const
 Fetch command line to be executed in this process. More...
 
int errorCode () const
 Fetch error code. More...
 
const String & errorMessage () const
 Fetch error message. More...
 
void terminate ()
 Terminates the process. More...
 
bool isAlive ()
 Verify if process is still alive. More...
 
int pid () const
 Fetch process PID. More...
 
int getLastErrorCode ()
 Returns the most recent error code. More...
 
void addEnvVariable (String name, String value)
 
void resetEnvVariableList ()
 

Public Member Functions

 Process (int pid)
 Create a new Process. A process created with a pid cannot be launched as it already should have been. terminate() and isAlive() functions can still be called with such a process. More...
 
 Process (String name,...)
 Create a new Process. More...
 
 Process (String name, StringList list)
 Create a new Process. More...
 
 Process (String commandLine)
 Create a new Process. More...
 

Detailed Description

The Process JavaScript class. Used to launch an external process.

Processes can be instantiated in the scripting environment.

p1 = new Process( "rndr -t file.rib" ); // create process from single string
p2 = new Process( "rndr", "-t", "file.rib" ); // create process using separate arguments
// Both commands execute same process
p1.launch();
p2.launch();
// Launch a new process and detach it from application.
// Application will not be monitored by script module.
p3 = new Process( "rndr -t file.rib" );
p3.launchAndDetach();
// Create a process from a specified PID.
p4 = new Process( 1234 );
// Verify if process is still alive and terminate it
if ( p4.isAlive() )
{
p4.terminate();
}

Constructor & Destructor Documentation

◆ Process() [1/4]

Process::Process ( int  pid)

Create a new Process. A process created with a pid cannot be launched as it already should have been. terminate() and isAlive() functions can still be called with such a process.

Parameters
pid: PID of already existing process.

◆ Process() [2/4]

Process::Process ( String  name,
  ... 
)

Create a new Process.

Parameters
name: Path or name of process to execute.
...: List of arguments.

◆ Process() [3/4]

Process::Process ( String  name,
StringList  list 
)

Create a new Process.

Parameters
name: Path or name of process to execute.
list: List of arguments.

◆ Process() [4/4]

Process::Process ( String  commandLine)

Create a new Process.

Parameters
commandLine: Entire command line to launch.

Member Function Documentation

◆ addEnvVariable

void Process::addEnvVariable ( String  name,
String  value 
)
slot

◆ commandLine

String Process::commandLine ( ) const
slot

Fetch command line to be executed in this process.

Returns
Returns the command line as a single string.

◆ errorCode

int Process::errorCode ( ) const
slot

Fetch error code.

Returns
Returns the error code. Returns 0 if no error.

◆ errorMessage

const String& Process::errorMessage ( ) const
slot

Fetch error message.

Returns
Returns the error message associated with the error code. Returns an empty string if no error.

◆ getLastErrorCode

int Process::getLastErrorCode ( )
slot

Returns the most recent error code.

Returns
The most recent error code.

◆ isAlive

bool Process::isAlive ( )
slot

Verify if process is still alive.

Returns
Returns the state of the process. Returns true if the process is still alive.

◆ launch

int Process::launch ( )
slot

Launch process.

Returns
Returns any error code. Returns 0 if no error.

◆ launchAndDetach

int Process::launchAndDetach ( )
slot

Launch process and detach it from application.

Returns
Returns any error code. Returns 0 if no error.

◆ pid

int Process::pid ( ) const
slot

Fetch process PID.

Returns
Returns the PID. Returns -1 if no process started.

◆ resetEnvVariableList

void Process::resetEnvVariableList ( )
slot

◆ terminate

void Process::terminate ( )
slot

Terminates the process.