zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: zargs with -P intermittently failing in zsh 5.9 and macOS
Date: Thu, 26 May 2022 17:57:45 +0900	[thread overview]
Message-ID: <F4E8CACF-ED46-4809-8977-37213538A0FE@kba.biglobe.ne.jp> (raw)
In-Reply-To: <CAH+w=7a4-QWdF1ApCjYs8YMwafeb1+_EyrgX=6BwRM6_0cwK8w@mail.gmail.com>


> 2022/05/25 2:32, Bart Schaefer <schaefer@brasslantern.com> wrote:
> 
>> +(eval):6> case 19 (<1-125>|128)
>> +(eval):8> ret=123
>> 
>> at least once, even though f always returned 0.
> 
> 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:

#!/bin/zsh
_zajobs=()
(   # works OK if not run in a subshell
    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

    #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
)

If I run this script on my Mac, a few (one or two in most cases, zero or
three sometimes) of the ten "wait $p" give $? = 19.

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
(3) run whole script in the main shell, i.e., remove the enclosing
"(" and ")", or
(4) replace "curl -so /dev/null 'https://example.com'" by "sleep 1",
or
(5) run the script on Linux (I haven't tried other BSDs).

(1)(2) may indicate that the first "wait" (without $p) can't correctly
wait for some of the child procs...?


  parent reply	other threads:[~2022-05-26  8:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24 16:09 Eric Nielsen
2022-05-24 17:32 ` Bart Schaefer
2022-05-24 20:21   ` Eric Nielsen
2022-05-24 20:35     ` Bart Schaefer
2022-05-26  8:57   ` Jun T [this message]
2022-05-26 11:21     ` Jun. T
2022-05-27  3:39     ` Bart Schaefer
2022-05-27  4:18       ` Lawrence Velázquez
2022-05-27  5:29       ` Jun T
2022-05-27 16:10         ` Bart Schaefer
2022-05-27 17:25           ` Jun. T
2022-05-29  3:30             ` Bart Schaefer
2022-05-29 14:47               ` Jun. T
2022-05-29 20:07                 ` Bart Schaefer
2022-05-30 11:16                   ` Jun T
2022-06-07  6:51                     ` Jun T
2022-06-09  2:56                       ` Bart Schaefer
2022-06-12 16:43                 ` Eric Nielsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F4E8CACF-ED46-4809-8977-37213538A0FE@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    --subject='Re: zargs with -P intermittently failing in zsh 5.9 and macOS' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).