From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19796 invoked by alias); 12 Mar 2018 13:34:14 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42452 Received: (qmail 7847 invoked by uid 1010); 12 Mar 2018 13:34:14 -0000 X-Qmail-Scanner-Diagnostics: from smtpfb2-g21.free.fr by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.27.42.10):SA:0(-1.3/5.0):. Processed in 2.001584 secs); 12 Mar 2018 13:34:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: acalando@free.fr X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Date: Mon, 12 Mar 2018 14:23:59 +0100 (CET) From: "Antoine C." To: zsh-workers@zsh.org Message-ID: <1328064061.551458859.1520861039419.JavaMail.root@zimbra62-e11.priv.proxad.net> Subject: [BUG?] "wait " sometimes confused with multiple childs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [193.194.132.77] X-Mailer: Zimbra 7.2.0-GA2598 (zclient/7.2.0-GA2598) X-Authenticated-User: acalando@free.fr Hello, I have a problem with a script starting several subshells in background then checking their return code. It looks like the "wait " builtin is sometimes returning the error code of another child. Here is a script reproducing this behavior. Several childs are started in a first loop with predefined return code, their PID saved, then we wait for each of them in a second loop and check their RC: ------start----- #!/bin/zsh while true; do pids=() for task in {1..16} ; do ( sleep .1 ; exit $task ) & pids+=($!) # uncomment to prevent bug #sleep .1 done for task in {1..16} ; do wait $pids[task] rc=$? if (( rc != task )) ; then echo " FAIL $pids[task]" $rc $task fi done echo "done $pids" done ------end----- On my machine, I have many "FAIL ..." printed, around 1 "FAIL" every 2 "done". If we comment out the "sleep" above, no more fails are printed. I also tried with bash (with a few syntax changes), and it is always working as expected. Is it a bug or am I missing something? Antoine