bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `wait -n` returns 127 when it shouldn't


From: Martin D Kealey
Subject: Re: `wait -n` returns 127 when it shouldn't
Date: Wed, 17 May 2023 17:23:21 +1000

On Wed, 17 May 2023 at 03:35, Aleksey Covacevice <
aleksey.covacevice@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

[Prev in Thread] Current Thread [Next in Thread]