Module lsh.pipeline.pstatus
Describes the result of the child processes of a pipeline after they have terminated.
This struct holds the exit statuses of the child processes.
The run method of lsh.pipeline and the wait method of
lsh.pipeline.children return it.
Functions
| new (children[, hang]) | Constructs a new pstatus instance. |
Status methods
| type () | Returns the type of the instance. |
| success (self) | Returns true if all processes exited with status zero. |
| codes (self) | Returns the array of exit codes of the processes. |
Functions
- new (children[, hang])
-
Constructs a new pstatus instance.
You do not need to call this function directly. Use lsh.pipeline.run or lsh.pipeline.spawn.
Parameters:
- children lsh.pipeline.children instance
- hang bool block until all processes exit (optional)
Returns:
-
lsh.pipeline.pstatus
pstatus
Or
-
boolean
falseif a process did not exit yetOr
- nil
- string error message
Status methods
- type ()
-
Returns the type of the instance.
Returns:
-
the string
"pipeline_status" - success (self)
-
Returns
trueif all processes exited with status zero.If a signal terminated a process, it returns
false.Parameters:
- self lsh.pipeline.pstatus
Returns:
-
bool
Usage:
local sh = require 'lsh' local status = sh.pipeline():add(sh.cmd('mkdir', '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.
For each process, see lsh.cmd.status.code.
Parameters:
- self lsh.pipeline.pstatus
Returns:
-
{number,...}
array of exit codes
Usage:
local sh = require 'lsh' local status = sh.pipeline():add(sh.cmd('ls')) :add(sh.cmd('tail')) :run() for i, code in ipairs(status:codes()) do print(("Process %d exited with status code: %d"):format(i, code)) end