bugfindutils - Bugs: bug #7340, xargs -n does not execute commands...

 
 

bug #7340: xargs -n does not execute commands in a timely manner

Submitted by:  Stewart Brodie <sbrodie>
Submitted on:  Tue 20 Jan 2004 02:15:50 PM UTC  
 
Category: xargsSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: James Youngman <jay>
Originator Name: Open/Closed: Closed
Release: NoneFixed Release: 4.2.9

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 05 Dec 2004 05:18:08 PM UTC, comment #4:

You can download a release of findutils in which this problem is
fixed from ftp://alpha.gnu.org/gnu/findutils.

The releases on alpha.gnu.org are for testing purposes, so please
take the time to download the release and verify that your
problem has been solved. Once the release has been sufficiently
tested, it can be uploaded to ftp.gnu.org for everybody to use it.

James Youngman <jay>
Project AdministratorIn charge of this item.
Wed 24 Nov 2004 05:01:00 PM UTC, comment #3:

This problem is fixed in the CVS code for findutils.
To resolve your problem, you could either wait for the
next official release of findutils, or check out a copy
of the code from the CVS repository for findutils.

James Youngman <jay>
Project AdministratorIn charge of this item.
Mon 01 Nov 2004 10:47:30 AM UTC, comment #2:

I disagree. I have improved testit.sh to more clearly demonstrate the problem. It now has two echo commands with a sleep between them. The first echo provides enough parameters for xargs to run immediately before the sleep occurs. It doesn't actually execute until the echo after the sleep has executed.

I have tested and reproduced this behaviour against both versions 4.1.7 and 4.2.3.

Stewart Brodie <sbrodie>
Sat 16 Oct 2004 08:20:23 PM UTC, comment #1:

I have just retested this problem in findutils 4.2.0 with the "testit.sh" script (attached). It looks right to me, could you comment on whether you agree?

James Youngman <jay>
Project AdministratorIn charge of this item.
Tue 20 Jan 2004 02:15:50 PM UTC, original submission:

When the number of parameters to the xargs subcommand is limited by using -n <num>, xargs does not execute the subcommand until it has seen the end of the input stream OR num+1 arguments. This can result in unnecessary delays in execution where the command to be executed is known (it has seen num args) since it isn't actually executed until more arguments are discovered (or the input stream ends).

A (lame, but the best I could think of right now) example which assumes date outputs 6 words:

$ for i in 1 2 3 4; do date;date;sleep 3; done | xargs -n 6

Example output from this is shown below, with me inserting <delay 3 seconds> where the 3 second delays occur:

Tue Jan 20 14:09:35 GMT 2004
<delay 3 seconds>
Tue Jan 20 14:09:35 GMT 2004
Tue Jan 20 14:09:38 GMT 2004
<delay 3 seconds>
Tue Jan 20 14:09:38 GMT 2004
Tue Jan 20 14:09:41 GMT 2004
<delay 3 seconds>
Tue Jan 20 14:09:41 GMT 2004
Tue Jan 20 14:09:44 GMT 2004
<delay 3 seconds>
Tue Jan 20 14:09:44 GMT 2004

There is no apparent reason why the delays are occurring where they are - the second echo should be being executed as soon as 6 parameters are available, no? I don't think that the current behaviour is desirable (and it's a nuisance for my use of it).

I've tested this against findutils 4.1.7, but I've examined the latest (revision 1.17 of xargs/xargs.c) in CVS and it hasn't changed in this regard.

I think it would be fairly easy to fix this behaviour by inserting a check for reaching max_args near the end of the push_arg function after the new (non-NULL) argument has been added to the argument array, and calling do_exec immediately if the limit has been reached.

But I'm not certain, hence I'm not supplying a proposed patch at the moment. Does anybody else agree?

Stewart Brodie <sbrodie>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #1953:  test_sb.sh added by sbrodie (86B - text/x-sh - Simple shell script demonstrating the delay)
file #1874:  testit.sh added by jay (179B - application/x-sh)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 7 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Sun 05 Dec 2004 05:18:08 PM UTCjayAssigned toNone=>jay
  Open/ClosedOpen=>Closed
  Fixed ReleaseNone=>4.2.9
Wed 24 Nov 2004 05:01:00 PM UTCjayStatusWorks For Me=>Fixed
Mon 01 Nov 2004 10:47:30 AM UTCsbrodieAttached File-=>Added test_sb.sh, #1825
Fri 22 Oct 2004 07:53:19 PM UTCjayStatusNone=>Works For Me
Sat 16 Oct 2004 08:20:23 PM UTCjayAttached File-=>Added testit.sh, #1767

Back to the top


Powered by Savane 3.1-cleanup1