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

2023-05-17 Thread Martin D Kealey
On Thu, 18 May 2023 at 02:13, Chet Ramey wrote: > It's possible for the shell to reap both background jobs before `wait -n' > is called. The underlying function returns < 0 when there aren't any > unwaited-for jobs, which the wait builtin translates to 127. > I know that some platforms (used

Re: Adding support of the z/OS platform

2023-05-17 Thread Chet Ramey
On 5/16/23 12:10 PM, Igor Todorovski wrote: Hi there, I’m looking for advice on the best way to submit a patch to enable support of z/OS. We have a few patches here which I will be cleaning up for the next few days: https://github.com/ZOSOpenTools/bashport/tree/main/patches You can just

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

2023-05-17 Thread Chet Ramey
On 5/16/23 1:35 PM, Aleksey Covacevice wrote: Bash Version: 5.1 Patch Level: 16 Release Status: release Description: `wait -n` sometimes returns with status code 127 even though there are unwaited-for children. There are not. That's why `wait -n' returns 127. Repeat-By: The following

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

2023-05-17 Thread Phi Debian
On Wed, May 17, 2023 at 12:21 PM Oğuz İsmail Uysal < oguzismailuy...@gmail.com> wrote: > > This boils down to the following > > true & > false & > wait -n > > There is no guarantee that `wait -n' will report the status of `true', > the shell may acquire the status of `false' first.

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

2023-05-17 Thread Robert Elz
Date:Wed, 17 May 2023 17:23:21 +1000 From:Martin D Kealey Message-ID: | I suspect putting "local" in a loop is doing something strange. "local" is an executable statement, not a declaration (shell really has none of the latter) - every time it is executed it

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

2023-05-17 Thread Oğuz İsmail Uysal
On 5/17/23 3:27 PM, Martin D Kealey wrote: On Wed, 17 May 2023 at 20:20, Oğuz İsmail Uysal wrote: On 5/16/23 8:35 PM, Aleksey Covacevice wrote: [original code elided as it's been mangled by line-wrapping] This boils down to the following true & false &

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

2023-05-17 Thread Oğuz İsmail Uysal
On 5/16/23 8:35 PM, Aleksey Covacevice wrote: waitjobs() { local status=0 while true; do local code=0; wait -n || code=$? ((code == 127)) && break ((!code)) || status=$code done return $status } # Eventually finishes: while true; do ( true & false & waitjobs ) && break; done This boils down

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

2023-05-17 Thread Martin D Kealey
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