[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: questions about coproc
From: |
Grisha Levit |
Subject: |
Re: questions about coproc |
Date: |
Thu, 9 Mar 2023 14:34:52 -0500 |
On Thu, Mar 9, 2023, 13:48 Britton Kerin <britton.kerin@gmail.com> wrote:
> 1. no obvious way to propagate e.g. the die argument in the above
> back to the controlling terminal. Is there some easy way to do this
> that I missed?
Maybe you mean something else by "propagate" but:
* stderr is inherited so goes to the terminal unless you've redirected it
when creating the coproc
* the coproc's termination can be detected by the <name>_PID variable
becoming unset (or `kill -0', etc)
* the coproc's exit status can be retrieved with `wait'
$ coproc c { read; echo err >&2; exit 5; }
[1] 16181
$ declare -p c_PID
declare -- c_PID="16181"
$ echo >&${c[1]}
err
[1]+ Exit 5 coproc c { read; echo err 1>&2; exit 5; }
$ declare -p c_PID
bash: declare: c_PID: not found
$ wait 16181; echo $?
5
>