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

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



> 2022/05/26 17:57, Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
> 
>        curl -so /dev/null 'https://example.com' & _zajobs+=( $! )

Sorry, curl fails (connection refused) if I test on my another Mac
in my home.

#!/bin/zsh
f () { curl -so /dev/null 'https://example.com'; return 0 }
_zajobs=()
(   # works OK if not run in a subshell
    np=20   #  try increasing this if you do not get $? = 19
    for ((i=0; i<$np; ++i)); do
        f & _zajobs+=( $! )
    done

    #sleep 1    # works OK if 'sleep 1' is added here
    wait        # works OK if this line is commented out
    for p in $_zajobs; do
        wait $p
        echo $p $?
    done
)

With this f(), the first pid in $_zajobs has the highest probability
to give $? = 19. If I replace f() by
f {} { date > /dev/null }
that takes much shorter time, and set np=20, then I get $? = 19 only
sometimes (not frequently), and the last (or the second last) pid in
$_zajobs has high probability to fail.





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