YaST2 Developers Documentation: SCR Process agent functions



SCR Process agent functions

Dir (.process) -> list

Return list od processes (IDs) managed by the process agent.

Example:

Dir(.process) -> [ 23568, 28896 ]

Write (.process, integer id, input_string) -> boolean

Wrtites the input string to stdin of the process. Returns true on success.

Example:

Write(.process, 12345, "foo") -> true

Read (.process.buffer_empty, integer id) -> boolean

Returns boolean whether the stdout buffer is empty, if buffer is not empty, false is returned.

Example:

Read (.process.buffer_empty, 12345) -> false

Execute (.process.close, integer id) -> integer

Close input/output of the process and wait until the process ends

Returns Exit value of the process

Example:

Execute(.process.close, 12345) -> 0

Execute (.process.kill, integer id, integer signal) -> boolean

Send a signal to the process, if signal is missing then SIGKILL is sent.

Example:

Execute(.process.kill, 12345, 15) -> true // send SIGTERM
Example:
Execute(.process.kill, 12345) -> true     // send SIGKILL

Read (.process.pid, integer id) -> integer

Returns the PID of a process

Example:

Read (.process.pid, 12345) -> 6789

Read (.process.read, integer id) -> string

Returns read stdout of the process, nil if there is no output. This read function is not line-oriented, the output can contain multiple lines or just part of a line.

Example:

Read (.process.read, 12345) -> nil

Read (.process.read_line, integer id) -> string

Returns one line from stdout of the process, nil if there is no output

Example:

Read (.process.read_line, 12345) -> nil

Read (.process.read_line_stderr, integer id) -> string

Returns one line from stderr of the process, nil if there is no output

Example:

Read (.process.read_line_stderr, 12345) -> nil

Read (.process.read_stderr, integer id) -> string

Returns read stderr of the process, nil if there is no output. This read function is not line-oriented, the output can contain multiple lines or just part of a line.

Example:

Read (.process.read_stderr, 12345) -> nil

Execute (.process.release, integer id) -> boolean

Removes the process from the internal structure and releases all allocated resources (buffers). If the process is running then it is killed by SIGKILL at first.

Example:

Execute(.process.release, 12345) -> true

Read (.process.running, integer id) -> boolean

Returns true if the process is running

Example:

Read (.process.running, 12345) -> true

Execute (.process.start, string command, map options) -> integer

Execute the command. The string command is a path to the program, arguments are passed in the map - value of key "args" must be list with the required arguments. For other options see .start_shell info.

Returns ID of the started process

Example:

Execute(.process.start, "/bin/echo", $[ "args" : [ "arg1", "arg2" ] ]) -> 12345

Execute (.process.start_shell, string command, map options) -> integer

Execute the command in a shell (/bin/sh). The command can contain all shell features like argument expansion, stdout/stderr redirection...

The optional map can contain additional configuration: "tty" : boolean - run the command in terminal (instead of piped stdout/stderr), the default is false, "C_locale" : boolean - use C locale (default false), "env" : map - set additional environment variables.

Returns ID of the started process

Example:

Execute(.process.start_shell, "/bin/true") -> 12345

Read (.process.status, integer id) -> integer

Returns exit status of the process, if the process is still running nil is returned.

Example:

Read (.process.status, 12345) -> 0

YaST2 Developers Documentation: SCR Process agent functions