Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: getting the status of the left-hand side of a pipe in the right-hand side



On Thu, Aug 1, 2019, 8:44 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:

> I would like to get the status of the left-hand side of a pipe
> in the right-hand size. Knowing whether it has terminated or not
> should be sufficient.
>
> Information is probably known from the job table
>

This is not the case in general.  The job status is only communicated by
the OS to the direct parent of the job, and the job table typically becomes
static in any subshell (it used to be completely erased in subshells but
people wanted to examine output of "jobs" for prompts etc.).

So you might be able to find the job from the job table but the best you
can reliably do for its status is to send it a "kill -0" and see if that
returns error.


Messages sorted by: Reverse Date, Date, Thread, Author