[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH 1/2] find: use sysconf(_SC_ARG_MAX) to determine the command-line size limit
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2014-06-25 13:45:05
Message-ID: CAK1hOcMzuudMn0AxP2z2Yoit7zuqKcW_Fk-Di-bnJbXR+D=4Ag () mail ! gmail ! com
[Download RAW message or body]

On Mon, Jun 23, 2014 at 5:35 PM, Bartosz Gołaszewski
<bartekgola@gmail.com> wrote:
> 2014-06-23 16:45 GMT+02:00 Ralf Friedl <Ralf.Friedl@online.de>:
>> According to a comment from findutils/xargs.c the 2048 comes from the
>> standard that for some reason limits the size of argv+environ to
>> ARG_MAX-2048 bytes.
>>
>> ARG_MAX is the total space available for all arguments. All arguments
>> include the environment, so the space needed for the environment is not
>> available for argv. Of course the space needed for the environment may be
>> smaller or much larger than 2048, so the 2048 is just a hack. The correct
>> approach would be to determine the size of the actual environment and use
>> that.
>
> I know it's just a hack of course, but you're right and I must have
> read the comment in <linux/limits.h> too fast: it's clearly stating
> that one must consider the space for the environment:
> #define ARG_MAX       131072    /* # bytes of args + environ for exec() */

BTW, the actual  limit was eliminated sometime ago
(it was ridiculous that we have machines with gigabytes of RAM but can't pass
a measly megabyte in argv[]).

Proof:

$ /bin/echo /*/*/*/* | wc -c
1320862
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic