Harmony
Scripting Interface Documentation
Process Class Reference

The Process JavaScript class. 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 ()
 Terminate process. More...
 
bool isAlive ()
 Verify if process is still alive. More...
 
int pid ()
 Fetch process PID. More...
 
void start (StringList *env=0)
 
void launch (String &buf, StringList *env=0)
 
String readStdout ()
 
String readStderr ()
 
bool canReadLineStdout ()
 
bool canReadLineStderr ()
 
String readLineStdout ()
 
String readLineStderr ()
 
void tryTerminate ()
 
void kill ()
 
void writeToStdin (String &buffer)
 
void closeStdin ()
 

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())
 
StringList arguments ()
 
void setArguments (StringList &arguments)
 
String workingDirectory ()
 
void setWorkingDirectory (String &workingDirectory)
 
bool running ()
 
int exitStatus ()
 

Properties

String objectName
 
StringList arguments
 
String workingDirectory
 
bool running
 
int exitStatus
 

Detailed Description

The Process JavaScript class. 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/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
pidPID of already existing process.

◆ Process() [2/5]

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

Create a new Process.

Parameters
namePath or name of process to execute
...List of arguments

◆ Process() [3/5]

Process::Process ( String  name,
StringList  list 
)

Create a new Process.

Parameters
namePath or name of process to execute
listList of arguments

◆ Process() [4/5]

Process::Process ( String  commandLine)

Create a new Process.

Parameters
commandLineEntire command line to launch

◆ Process() [5/5]

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

Member Function Documentation

◆ arguments()

StringList Process::arguments ( )

◆ canReadLineStderr

bool Process::canReadLineStderr ( )
slot

◆ canReadLineStdout

bool Process::canReadLineStdout ( )
slot

◆ closeStdin

void Process::closeStdin ( )
slot

◆ commandLine

String Process::commandLine ( )
slot

Fetch command line to be executed in this process.

Returns
command line in a single string

◆ errorCode

int Process::errorCode ( )
slot

Fetch error code.

Returns
error code, zero if none

◆ errorMessage

String& Process::errorMessage ( )
slot

Fetch error message.

Returns
error message associated to error code, empty string if none

◆ exitStatus()

int Process::exitStatus ( )

◆ isAlive

bool Process::isAlive ( )
slot

Verify if process is still alive.

Returns
state of process, true if it can be reached

◆ kill

void Process::kill ( )
slot

◆ launch [1/2]

int Process::launch ( )
slot

Launch process.

Returns
error code, zero if none

◆ launch [2/2]

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

◆ launchAndDetach

int Process::launchAndDetach ( )
slot

Launch process and detach it from application.

Returns
error code, zero if none

◆ launchFinished

void Process::launchFinished ( )
signal

◆ pid

int Process::pid ( )
slot

Fetch process PID.

Returns
pid, -1 if no process started

◆ processExited

void Process::processExited ( )
signal

◆ readLineStderr

String Process::readLineStderr ( )
slot

◆ readLineStdout

String Process::readLineStdout ( )
slot

◆ readStderr

String Process::readStderr ( )
slot

◆ readStdout

String Process::readStdout ( )
slot

◆ readyReadStderr

void Process::readyReadStderr ( )
signal

◆ readyReadStdout

void Process::readyReadStdout ( )
signal

◆ running()

bool Process::running ( )

◆ setArguments()

void Process::setArguments ( StringList &  arguments)

◆ setWorkingDirectory()

void Process::setWorkingDirectory ( String &  workingDirectory)

◆ start

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

◆ terminate

void Process::terminate ( )
slot

Terminate process.

◆ tryTerminate

void Process::tryTerminate ( )
slot

◆ workingDirectory()

String Process::workingDirectory ( )

◆ writeToStdin

void Process::writeToStdin ( String &  buffer)
slot

◆ 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