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

Re: zargs with -P intermittently failing in zsh 5.9 and macOS



On Thu, May 26, 2022 at 1:58 AM Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> > 2022/05/25 2:32, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > Something is causing the subshell that was running f to exit with
> > status 19 even though f returned 0.
>
> The problem can be reproduced by the following simplified script:

Thanks.  Is this limited to newer MacOS, like the nullexec test
discussed in workers/50164 ?

> (   # works OK if not run in a subshell

Interesting.  It may actually be possible to remove the subshell from
zargs now (see below).

>     np=10   # try increasing this if you do not get $? = 19
>     for ((i=0; i<$np; ++i)); do
>         curl -so /dev/null 'https://example.com' & _zajobs+=( $! )
>     done

I don't suppose you've found any indication of what 19 actually means, there.

>     #sleep 1    # works OK if 'sleep 1' is added here
>     wait        # works OK if this line is commented out

Hm.  If that wait is removed, the subshell is probably not necessary.
It's there because of a lingering concern that if we didn't first wait
for all jobs to finish before starting the individual waits, we might
get race conditions. It seems like perhaps the opposite is actually
the case.

> But all the "wait $p" return 0 if
> (1) remove the "wait" before the "for p in $_zajobs", or
> (2) add "sleep 1" before the "wait", or
>
> (1)(2) may indicate that the first "wait" (without $p) can't correctly
> wait for some of the child procs...?

That would be ... strange ... and would mean we might have to be on
the lookout for "wait" failing in other cases too.




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