On Wed, 17 May 2023 at 03:35, Aleksey Covacevice <
aleksey.covacev...@gmail.com> wrote:

> Description:
> `wait -n` sometimes returns with status code 127 even though there are
> unwaited-for children.
>
> Repeat-By:
> The following script does finish after a while:
>
> waitjobs() {
>     local status=0
>     while true; do
>     local code=0; wait -n || code=$?
>

I put "local code" out of the loop and the problem went away (or at least
became extremely less likely).
I suspect putting "local" in a loop is doing something strange.




>         ((code == 127)) && break
>         ((!code)) || status=$code
>     done
>     return $status
> }
>
> # Eventually finishes:
> while true; do (
>     true &
>     false &
>     waitjobs
> ) && break; done
>

I'm testing with Bash 5.1.4p47

-Martin

Reply via email to