[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xargs -p operations out of order!

From: Eric Blake
Subject: Re: xargs -p operations out of order!
Date: Wed, 31 Jul 2013 16:11:12 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 07/31/2013 04:00 PM, Bernhard Voelker wrote:
> Hi Eric,
> On 07/31/2013 07:10 PM, Eric Blake wrote:
>> On 07/31/2013 11:01 AM, address@hidden wrote:
>>> $ seq 111|xargs -n 5 -p
>> Sorry, but this is not xargs' fault.  You asked xargs to spawn multiple
>> processed in parallel, [...]
> I'm not sure:
> the OP used lower-case -p, so xargs is spawning only _one_ process:

Oh, I totally misread the report, and thought it was complaining about
upper-case -P.

>   $ xargs --help
>   [...]
>     -n, --max-args=MAX-ARGS      use at most MAX-ARGS arguments per command 
> line
>     -P, --max-procs=MAX-PROCS    run at most MAX-PROCS processes at a time
>     -p, --interactive            prompt before running commands
> But the effect is the same: with today's implementation, the 'echo'
> process is in parallel to the 'GNU xargs' process asking if it
> should spawn the next 'echo' process.

so the real race here is between xargs prompting about the next command
to be run, vs. the execution of the echo command.

> Hmm, POSIX says:
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html
>   The xargs utility shall then invoke the constructed command line
>   and wait for its completion. This sequence shall be repeated until
>   one of the following occurs: [...]

Indeed, I think you have a real bug after all - xargs should not be
prompting for the fourth command until after it reaps the echo process
spawned by the affirmative answer to the third prompt.

> Do I read it correct?

Yes, I think your reading of POSIX shows we have a bug in xargs.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]