zsh-users
 help / color / mirror / code / Atom feed
From: Philippe Troin <phil@fifi.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Perry Smith <pedz@easesoftware.com>, Zsh Users <zsh-users@zsh.org>
Subject: Re: Parallel processing
Date: Sun, 27 Mar 2022 10:32:39 -0700	[thread overview]
Message-ID: <b84b8855cc6c8f7e1d30ee37169b158c68188c93.camel@fifi.org> (raw)
In-Reply-To: <CAH+w=7ZRAQTVBfvw1XN=2xEGVNf2ShD6eck+_iv=fGLcEqBLBg@mail.gmail.com>

On Sat, 2022-03-26 at 15:19 -0700, Bart Schaefer wrote:
> On Sat, Mar 26, 2022 at 11:10 AM Philippe Troin <phil@fifi.org> wrote:
> 
> 
> > Anyways, zargs is not doing a stellar job currently with collecting
> > exit statuses from commands ran in parallel:
> 
> # Everything has to be in a subshell just in case of backgrounding jobs,
> # so that we don't unintentionally "wait" for jobs of the parent shell.
> 
> Hmm ... zargs uses
>   wait ${${jobstates[(R)running:*]/#*:/}/%=*/}
> to wait for all the backgrounded jobs that it started.  (This causes a
> segfault in the most recent git checkout if zargs itself is a subshell
> job.)  However, that "wait" returns the exit status of only one of
> those jobs.  There might be something more that could be done now, to
> pick up the status of the rest ... but I'm reluctant to mess with that
> while the segfault is unfixed.
> 
> >    % zargs -n 4 -P 2 -- 0 1 -- zsh -c 'sleep $1 ; exit $1 ' -; echo $?
> >    123
> 
> This is explained in the comments in zargs:
> 
> # Like xargs, zargs exits with the following status:
> #   0 if it succeeds
> #   123 if any invocation of the command exited with status 1-125
> #   124 if the command exited with status 255
> #   125 if the command is killed by a signal
> #   126 if the command cannot be run
> #   127 if the command is not found
> #   1 if some other error occurred.

I was referring to the fact that zargs misses the exit status of
subcommands:

   % zargs -n 4 -P 2 -- 1 0 -- zsh -c 'sleep $1 ; exit $1 ' -; echo $?
   0
   % zargs -n 4 -P 2 -- 0 1 -- zsh -c 'sleep $1 ; exit $1 ' -; echo $?
   123

Both zargs invocation will spawn two subcommands.  In both cases one
subcommand will exit with status 0 and the other with status 1.

In the first invocation, zargs misses that one of the subshells returns
non-zero exit status.

Phil.


  reply	other threads:[~2022-03-27 17:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25  4:34 Perry Smith
2022-03-25 18:27 ` Bart Schaefer
2022-03-26 18:10   ` Philippe Troin
2022-03-26 22:19     ` Bart Schaefer
2022-03-27 17:32       ` Philippe Troin [this message]
2022-03-27 17:42         ` Bart Schaefer
2022-03-27 19:23 ` Dominik Vogt
2022-03-28 13:26   ` Perry Smith
2022-03-28 13:31 ` Perry Smith
2022-03-26  4:34 jdh
2022-03-27 18:37 jdh
2022-03-27 19:06 ` Bart Schaefer
2022-03-27 19:24   ` Ray Andrews
2022-03-28 13:47 ` Perry Smith

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=b84b8855cc6c8f7e1d30ee37169b158c68188c93.camel@fifi.org \
    --to=phil@fifi.org \
    --cc=pedz@easesoftware.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).