bug-findutils
[Top][All Lists]
Advanced

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

cygwin xargs limitation: ARG_MAX depends on command


From: Eric Blake
Subject: cygwin xargs limitation: ARG_MAX depends on command
Date: Mon, 05 Sep 2005 14:01:53 -0600
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Cygwin has an interesting situation affecting xargs 4.2.25, where the
maximum command-line length of a command is determined by the command
being executed.  If the command lives on a cygwin-executable mount, the
command line is passed using cygwin internal memory, and can easily be
several megabytes.  But in the typical situation, the command lives on a
normal Windows mount, where the command line goes through the Windows API
CreateProcess which has a 32k limit.  xargs, by default, wants to use 128k
+ environment_size, which means that on a non-cygexec mount it has a good
chance of exceeding the max argument limitation.

For example, I have /bin and /usr/bin mounted to the same location, but
only /bin is mounted as cygwin-executable:
$ ls -iF /bin/echo /usr/bin/echo
1688849860332071 /bin/echo*  1688849860332071 /usr/bin/echo*
$ mount | grep '/bin\b'
c:\cygwin\bin on /usr/bin type system (binmode)
c:\cygwin\bin on /bin type system (binmode,cygexec)
$ /bin/echo `seq 7800` | wc
      1    7800   37893
$ /usr/bin/echo `seq 7800` | wc
bash: /usr/bin/echo: Argument list too long
      0       0       0

The problem is that POSIX requires that ARG_MAX, if defined, be a
constant, and that sysconf(_SC_ARG_MAX) be constant for the life of a
process, as well as being no less than ARG_MAX if it was defined.  Cygwin
1.5.18 does not define ARG_MAX, and sysconf(_SC_ARG_MAX) returns 1 meg,
meaning that xargs violates the 32k limit of non-cygexec mounts.  But even
if cygwin 1.5.19 were to define ARG_MAX and changes sysconf(_SC_ARG_MAX)
to 32k instead of 1 meg, this would unfairly penalize cygexec mounts,
which can handle much bigger command lines.  sysconf() has no way of
conveying the dependence of the maximum argument length on the command
being exec*()'d.  pathconf() sounds like a perfect candidate for this type
of dependence, although there is no POSIX-mandated configuration variable
that captures argument length as a factor of pathname.  Is there any other
system where the max argument length depends on the command?  Would you
accept a patch that changes lib/buildcmd.c to accept the command to be
exec'd as a parameter, so that on cygwin it can return either 32k or 4 meg
depending on whether cygwin detects that the file to be exec'd is mounted
cygexec?

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDHKQx84KuGfSFAYARApPjAJ9Ee6itSmaagi9pcdMMb6Gu6UtLZACgz/tW
vzQ3aoXdYC5pRgDbYCuReus=
=tNRa
-----END PGP SIGNATURE-----




reply via email to

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