Module lsh.pipeline.pstatus
Describes the result of a pipeline children processes after they have terminated.
This struct is used to represent the exit statuses of a children processes.
Children processes are created via the lsh.pipeline struct and their exit
statuses are exposed through the run
method, or the wait
method of
a lsh.pipeline.children processes.
Functions
new (children[, hang]) | Constructs the new pstatus instance. |
Status methods
type () | Returns the type of a instance. |
success (self) | Was termination successful? |
codes (self) | Returns the array of exit codes of the processes, if any. |
Functions
- new (children[, hang])
-
Constructs the new pstatus instance.
There is no need to use this method directly, see lsh.pipeline.run and lsh.pipeline.spawn for practical program execution.
Parameters:
- children lsh.pipeline.children instance
- hang bool hang by default (optional)
Returns:
-
lsh.pipeline.pstatus
pstatus
Or
-
boolean
false if process didn't terminate
Status methods
- type ()
-
Returns the type of a instance.
Returns:
-
the string
"pipeline_status"
- success (self)
-
Was termination successful?
Signal termination is not considered a success, and success is defined as a zero exit status.
Parameters:
- self lsh.pipeline.pstatus
Returns:
-
bool
Usage:
local sh = require 'lsh' local status = sh.pipeline():add('mkdir'):arg('projects') :run() if status:success() then print('"projects/" directory created') else print('failed to create "projects/" directory') end
- codes (self)
-
Returns the array of exit codes of the processes, if any.
It will return
nil
if the processes were terminated by a signal.Parameters:
- self lsh.pipeline.pstatus
Returns:
-
number
Or
-
nil
Usage:
local sh = require 'lsh' local status = sh.cmd('mkdir'):arg('projects') :run() local code = status:code() if code then print(("Exited with status code: %d"):format(code)) else print('Process terminated by signal') end