The Process class is used to manage processes that are started by the EXEC or SHELL instructions. When you call either instruction, the interpreter translates that into a call to a routine from a system library it is linked to. The interpreter starts a child process.
You can not create an object from the Process class yourself, as is possible with other classes and the NEW instruction, for example. This can only be done by calling the EXEC and SHELL instructions. For example, you can start a process with an instruction like the following:
ProzessVariable = SHELL sCommand FOR READ WRITE AS "MyProcess"
in order to then intercept, evaluate and display the output of this process with MyProcess_Read and MyProcess_Error, among other things, and to react to it because you started it yourself. Since the Process class is derived from the (base) Stream class, you can work with its input/output statements to read from the standard output or send data directly to the process. To read and evaluate the error output of the started process, you must use the Error event.
In addition to dynamic properties, the Process class also has static properties that are shared by all instances of the class. These are:
The dynamic properties of the Process class, specific to each object, are explained in the following table:
Property | Description |
---|---|
Handle | The process ID (PID) of the process on the system |
Id | Synonym for Handle |
Status | The current status of the process (4 values) |
Value | The return value of the process once it has finished (0=successful, values greater than zero indicate an error) |
Table 21.1.1: Properties of the class Process
The State property indicates the state of a process. The Process class provides the following symbolic constants to reflect different process states:
State constant | Numeric value | Description |
---|---|---|
Stopped | 0 | A process was stopped |
Running | 1 | A process has been started and is running |
Crashed | 2 | A process crashed |
Signaled | 2 | Synonym for Crashed |
Table 21.1.2: Process states - constants and numerical values
As methods for process control, the class provides you with only two usable ones:
Method | Description |
---|---|
Kill | Terminate a process via the signal SIGKILL |
Wait | Wait for the end of a process |
Table 21.1.3: Methods of the class Process
A process knows the events:
Event | Description |
---|---|
Kill | This event is triggered when the process has been terminated. |
Error | This event is triggered when an error occurred and data can be read (indirectly) from the standard error output of the process. |
Read | This event is triggered when data can be read from the standard output of the process. |
Table 21.1.4: Events of the class Process