[Toybox] [PATCH] xargs: avoid "Argument list too long".

enh enh at google.com
Sun Oct 20 22:39:24 PDT 2019


It turns out that findutils xargs almost always uses an artificially low
limit of 128KiB. You can observe this with --show-limits (which I
refrained from adding to toybox since I believe it's only useful if
you're debugging a broken xargs).

I think an alternative fix for all this would be to go back to counting
the cost of the (char *)s, but separate the -s limit from the "system"
limit --- that way we could have the same behavior as findutils xargs
for explicit values of -s (which we all seem to agree should *not*
include the cost of the (char *)s), but also not accidentally overrun
the actual system limits when we do count the (char *)s. That's more
complicated though, and findutils' "128KiB is enough for anyone"
behavior is demonstrably "good enough", so let's go with that for now.

Tested by building an Android common kernel with toybox xargs, which
failed before.

Also tested with `find /usr | xargs > /dev/null`, which fails with
toybox xargs even on my laptop.

  ~$ find /usr | wc
   262823  262835 15132761

(On my desktop, even `find /proc` is sufficient to hit this!)

Bug: http://b/140269206
---
 toys/posix/xargs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-xargs-avoid-Argument-list-too-long.patch
Type: text/x-patch
Size: 2524 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20191020/5e407e93/attachment-0002.bin>


More information about the Toybox mailing list