Process Class Reference

The Process2 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 ()
 Fetch command line to be executed in this process. More...
 
int errorCode ()
 Fetch error code. More...
 
String & errorMessage ()
 Fetch error message. More...
 
void terminate ()
 Terminates the process. More...
 
bool isAlive ()
 Verify if process is still alive. More...
 
int pid ()
 Fetch process PID. More...
 
void addEnvVariable (String name, String value)
 
void resetEnvVariableList ()
 
void start (StringList *env=0)
 Starts the process. More...
 
void launch (String &buf, StringList *env=0)
 Launches the Process. More...
 
String readStdout ()
 Returns the contents of the Standard output file. More...
 
String readStderr ()
 Returns the contents of the Standard error file. More...
 
bool canReadLineStdout ()
 Returns true if you can read the Standard output file line by line. More...
 
bool canReadLineStderr ()
 Retruns true if you can read the Standard error file line by line. More...
 
String readLineStdout ()
 Returns the next line of the Standard output file. More...
 
String readLineStderr ()
 Returns the next line of the Standard error file. More...
 
void tryTerminate ()
 Tries to terminate the process. More...
 
void kill ()
 Kills the process. More...
 
void writeToStdin (String &buffer)
 Writes to the Standard input file. More...
 
void closeStdin ()
 Closes the Standard input file. More...
 

Signals

void readyReadStdout ()
 
void readyReadStderr ()
 
void processExited ()
 
void wroteToStdin ()
 
void launchFinished ()
 

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...
 
 Process (StringList &args=StringList())
 Create a new Process. More...
 
StringList arguments ()
 Returns the arguments for the process. More...
 
void setArguments (StringList &arguments)
 Sets the arguments for running the process. More...
 
String workingDirectory ()
 Returns the current working directory. More...
 
void setWorkingDirectory (String &workingDirectory)
 Sets the current working directory. More...
 
bool running ()
 Returns true if the process is running. More...
 
int exitStatus ()
 Whether or not running the process was a failure. A non-zero exit status indicates failure. More...
 

Properties

String objectName
 
StringList arguments
 
String workingDirectory
 
bool running
 
int exitStatus
 

Detailed Description

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

Processes can be instantiated in the scripting environment.

p1 = new Process2( "rndr -t file.rib" ); // create process from single string
p2 = new Process2( "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 Process2( "rndr -t file.rib" );
p3.launchAndDetach();
// Create a process from a specified PID.
p4 = new Process2( 1234 );
// Verify if process is still alive and terminate it
if ( p4.isAlive() )
{
p4.terminate();
}

Constructor & Destructor Documentation

◆ Process() [1/5]

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/5]

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

Create a new Process.

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

◆ Process() [3/5]

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/5]

Process::Process ( String  commandLine)

Create a new Process.

Parameters
commandLine: Entire command line to launch.

◆ Process() [5/5]

Process::Process ( StringList &  args = StringList())

Create a new Process.

Parameters
args: A StringList of arguments.

Member Function Documentation

◆ addEnvVariable

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

◆ arguments()

StringList Process::arguments ( )

Returns the arguments for the process.

Returns
The arguments for the process.

◆ canReadLineStderr

bool Process::canReadLineStderr ( )
slot

Retruns true if you can read the Standard error file line by line.

Returns
True if you can read the Standard error file line by line.

◆ canReadLineStdout

bool Process::canReadLineStdout ( )
slot

Returns true if you can read the Standard output file line by line.

Returns
True if you can read the Standard output file line by line.

◆ closeStdin

void Process::closeStdin ( )
slot

Closes the Standard input file.

◆ commandLine

String Process::commandLine ( )
slot

Fetch command line to be executed in this process.

Returns
Returns the command line as a single string.

◆ errorCode

int Process::errorCode ( )
slot

Fetch error code.

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

◆ errorMessage

String& Process::errorMessage ( )
slot

Fetch error message.

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

◆ exitStatus()

int Process::exitStatus ( )

Whether or not running the process was a failure. A non-zero exit status indicates failure.

Returns
The exist status.

◆ 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.

◆ kill

void Process::kill ( )
slot

Kills the process.

◆ launch [1/2]

int Process::launch ( )
slot

Launch process.

Returns
Returns -1 if any error or process has been aborted, else return the process exit code, success is 0 in most of the time.

◆ launch [2/2]

void Process::launch ( String &  buf,
StringList *  env = 0 
)
slot

Launches the Process.

Parameters
buf: The data to write.
env: The process environment.

◆ launchAndDetach

int Process::launchAndDetach ( )
slot

Launch process and detach it from application.

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

◆ launchFinished

void Process::launchFinished ( )
signal

◆ pid

int Process::pid ( )
slot

Fetch process PID.

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

◆ processExited

void Process::processExited ( )
signal

◆ readLineStderr

String Process::readLineStderr ( )
slot

Returns the next line of the Standard error file.

Returns
The next line of the Standard error file.

◆ readLineStdout

String Process::readLineStdout ( )
slot

Returns the next line of the Standard output file.

Returns
The next line of the Standard output file.

◆ readStderr

String Process::readStderr ( )
slot

Returns the contents of the Standard error file.

Returns
The contents of the Standard error file.

◆ readStdout

String Process::readStdout ( )
slot

Returns the contents of the Standard output file.

Returns
The contents of the Standard output file.

◆ readyReadStderr

void Process::readyReadStderr ( )
signal

◆ readyReadStdout

void Process::readyReadStdout ( )
signal

◆ resetEnvVariableList

void Process::resetEnvVariableList ( )
slot

◆ running()

bool Process::running ( )

Returns true if the process is running.

Returns
True if the process is running.

◆ setArguments()

void Process::setArguments ( StringList &  arguments)

Sets the arguments for running the process.

Parameters
arguments: A StringList of arguments.

◆ setWorkingDirectory()

void Process::setWorkingDirectory ( String &  workingDirectory)

Sets the current working directory.

Parameters
workingDirectory: The path to the desired working directory.

◆ start

void Process::start ( StringList *  env = 0)
slot

Starts the process.

Parameters
env: The process environment.

◆ terminate

void Process::terminate ( )
slot

Terminates the process.

◆ tryTerminate

void Process::tryTerminate ( )
slot

Tries to terminate the process.

◆ workingDirectory()

String Process::workingDirectory ( )

Returns the current working directory.

Returns
The current working directory.

◆ writeToStdin

void Process::writeToStdin ( String &  buffer)
slot

Writes to the Standard input file.

Parameters
buffer: The data to write.

◆ wroteToStdin

void Process::wroteToStdin ( )
signal

Property Documentation

◆ arguments

StringList Process::arguments
readwrite

◆ exitStatus

int Process::exitStatus
read

◆ objectName

String Process::objectName

◆ running

bool Process::running
read

◆ workingDirectory

String Process::workingDirectory
readwrite