User Tools

Site Tools


k21:k21.1:start

21.1 Class Process

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:

  • LastState → The state of the most recently terminated Process object.
  • LastValue → Return value of the last terminated Process object.

The dynamic properties of the Process class, specific to each object, are explained in the following table:

Property Description
HandleThe process ID (PID) of the process on the system
IdSynonym for Handle
StatusThe current status of the process (4 values)
ValueThe 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 constantNumeric valueDescription
Stopped0A process was stopped
Running1A process has been started and is running
Crashed2A process crashed
Signaled2Synonym 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:

MethodDescription
KillTerminate a process via the signal SIGKILL
WaitWait for the end of a process

Table 21.1.3: Methods of the class Process

A process knows the events:

EventDescription
KillThis event is triggered when the process has been terminated.
ErrorThis event is triggered when an error occurred and data can be read (indirectly) from the standard error output of the process.
ReadThis event is triggered when data can be read from the standard output of the process.

Table 21.1.4: Events of the class Process

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k21/k21.1/start.txt · Last modified: 18.05.2022 (external edit)

Page Tools