[Toybox] [landley/toybox] xargs: exec ... Argument list too long (#40)

Rob Landley rob at landley.net
Mon Aug 15 00:06:12 PDT 2016


On 08/13/2016 04:36 PM, enh wrote:
>>> Oh well, use the sysconf and then file a bug against musl. (Elliott will
>>> probably notice this, and if not he'll notice the commit.)
>>
>> yeah, this is as good a bionic bug reporting forum as any :-)
> 
> fixed in AOSP. (took a while to kill code in the internal tree making
> bad assumptions about ARG_MAX...)

I've gotta add the measuring code back to find.

There's also this fun little corner case from susv4's xargs page

> The xargs utility shall limit the command line length such that when
> the command line is invoked, the combined argument and environment
> lists (see the exec family of functions in the System Interfaces
> volume of POSIX.1-2008) shall not exceed {ARG_MAX}-2048 bytes.
> Within this constraint, if neither the -n nor the -s option is
> specified, the default command line length shall be at least
> {LINE_MAX}.

So they want a gratuitous -2048 constant in there. I don't know if this
is because they're _not_ measuring the space used by the actual argv[]
and envp[] pointer arrays, or because they're leaving space for the new
command to add extra environment data to itself, or...?

I'm leaning towards doing another "nuts to your white mice" at posix's
magic constant here and just actually measuring the real-world things
they never mention the existence of. Or I could just hardwire a random
default like they suggest and let people -s specify it if they know what
they're doing. (Alas, I've run out of weekend...)

Rob


More information about the Toybox mailing list