User Tools

Site Tools


DzProcess

A class for starting/communicating with external programs.

More...

Inherits :

Enumerations

Properties

Constructors

DAZ Script
DzProcess ()
DzProcess ( Array args )
DzProcess ( String arg0 )

Methods

Signals

Detailed Description

See the render to rib sample (line #440+), to see this class in action.

Enumerations


Communication : Stdin, Stdout, Stderr, DupStderr

Defines the communication channels connected to the process.

Properties


Array : arguments

Holds an Array of strings. The first being the program to execute, the rest being the command line arguments.


Communication : communication

Holds the communication for the process.


Number : exitStatus

Holds the exit status of the program when it has finished. 0 if the process is still running. (Read Only)


Boolean : normalExit

Holds whether or not the process has exited normally. (Read Only)


Boolean : running

Holds whether or not the process is currently running. (Read Only)


String : workingDirectory

Holds the working directory for the process.

Constructors


DzProcess()

Default Constructor.

Creates a DzProcess object without specifying the program or arguments. This does NOT start start the process.


DzProcess( Array args )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Creates a DzProcess object specifying the program and any arguments. The first element of args is the program to execute, the rest are the command line arguments. This does NOT start start the process.


DzProcess( String arg0 )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Creates a DzProcess object specifying only the program, without any arguments. This does NOT start start the process.

Methods


Boolean : canReadLineStderr()

Return Value:

  • true if it is possible to read an entire line of text from standard error, otherwise false.

Boolean : canReadLineStdout()

Return Value:

  • true if it is possible to read an entire line of text from standard output, otherwise false.

void : closeStdin()

Closes the process' standard input and deletes any pending data that hasn't been written to standard input.


void : kill()

Terminates the process.

Attention:

  • This is not a safe way to end a process, as the process will not be able to perform any cleanup. tryTerminate() is safer, but process' can ignore it.

Boolean : launch( String buffer, Array env=0 )

Attempts to run the process, writing buffer to the process' standard input. Standard input is closed if all of the data in buffer is written to it. If envis specified, the values in the Array [of strings] are interpreted as environment settings in the form VARIABLE=VALUE, and the process is started with these environment settings. If envis not specifiied, the process is started with the same environment settings as the starting process.

Return Value:

  • true if the process was able to start, otherwise false.

String : readLineStderr()

Return Value:

  • A line of text from standard error, minus any trailing newline or carriage return characters if canReadLineStderr() is true, otherwise an empty string.

String : readLineStdout()

Return Value:

  • A line of text from standard output, minus any trailing newline or carriage return characters if canReadLineStdout() is true, otherwise an empty string.

String : readStderr()

Reads the data that the process has written to standard error. When new data is written, the readyReadStderr() signal is emitted.

Return Value:

  • The data written to standard error, or an empty string if there is no such data.

Attention:

  • This method does not wait for there to be something to read.

String : readStdout()

Reads the data that the process has written to standard output. When new data is written, the readyReadStdout() signal is emitted.

Return Value:

  • The data written to standard output, or an empty string if there is no such data.

Attention:

  • This method does not wait for there to be something to read.

Boolean : start( Array env=0 )

Attempts to run the process for the program and arguments specified with the arguments property or as specified in the constructor. If envis specified, the values in the Array [of strings] are interpreted as environment settings in the form VARIABLE=VALUE, and the process is started with these environment settings. If envis not specifiied, the process is started with the same environment settings as the starting process.

Return Value:

  • true if the process was able to start, otherwise false.

void : tryTerminate()

Attempts to terminate the process.

Attention:

  • Process' can ignore this, if they choose to. If you want to be certain that the process is terminated, use kill() instead.

void : writeToStdin( String buffer )

Writes buffer to standard input. The process may, or may not, read the data. The wroteToStdin() signal is emitted once all data in buffer has been written to the process.

Signals


void : launchFinished()

Signature:“launchFinished()”

Emitted when the process is started with launch(). If starting the process is successful, this signal is emitted after the data passed in has been written to standard input. If starting the process fails, this signal is emitted immediately.


void : processExited()

Signature:“processExited()”

Emitted when the process has exited.


void : readyReadStderr()

Signature:“readyReadStderr()”

Emitted when the process has written data to standard error.


void : readyReadStdout()

Signature:“readyReadStdout()”

Emitted when the process has written data to standard output.


void : wroteToStdin()

Signature:“wroteToStdin()”

Emitted if the data sent to standard input (via writeToStdin()) was actually written to the process.