[Top][All Lists]

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

Re: xargs -p operations out of order!

From: Bernhard Voelker
Subject: Re: xargs -p operations out of order!
Date: Thu, 01 Aug 2013 00:00:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

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:

  $ 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.

Hmm, POSIX says:

  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: [...]


  The version of xargs required by this volume of POSIX.1-2008 is
  required to wait for the completion of the invoked command before
  invoking another command. This was done because historical scripts
  using xargs assumed sequential execution. Implementations wanting to
  provide parallel operation of the invoked utilities are encouraged to
  add an option enabling parallel invocation, but should still wait for
  termination of all of the children before xargs terminates normally.

I read it like as GNU xargs is free to support multiple, parallel
processes - it does via the -P option - but if -P is not given (or
-P1 is specified), then it should follow the POSIX spec, i.e., it
should wait.  Okay, the behaviour in the case of parallelism > 1
may be undefined.

Do I read it correct?

Have a nice day,

reply via email to

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