On Mon, Jun 23, 2014 at 5:35 PM, Bartosz Gołaszewski <[email protected]> wrote: > 2014-06-23 16:45 GMT+02:00 Ralf Friedl <[email protected]>: >> 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 [email protected] http://lists.busybox.net/mailman/listinfo/busybox
