Mailinglist Archive: opensuse (2459 mails)

< Previous Next >
Re: [opensuse] limits.h (was /bin/rm: Argument list too long)
  • From: Randall R Schulz <rschulz@xxxxxxxxx>
  • Date: Sat, 29 Mar 2008 07:48:33 -0700
  • Message-id: <200803290748.33712.rschulz@xxxxxxxxx>
On Saturday 29 March 2008 07:36, Wolfgang Woehl wrote:
Sam Clemens:
Randall R Schulz wrote:
On Friday 28 March 2008 01:23, Wolfgang Woehl wrote:
Where can I read the argument list size limit? I fail to see
anything relevant with ulimit -a or in proc or in pam's
limits.conf.

% egrep ARG_MAX /usr/include/linux/limits.h
#define ARG_MAX 131072 /* # bytes of args + environ for
exec() */

Aha. Is there a decent method to calculate the size of any given
argv[] and thereby learn whether a process will exceed and fail?

It's the number of bytes of argument + the number of arguments (the
latter term accounts for the NUL byte at the end of each argument).

The environment is identical to arguments for this purpose, so you need
to add in the size of the environment (names and equal signs included)
plus the number of environment variables. You can get that by simply
using $(env |wc -c). That works because the newlines in the env output
take the places of the NULs used internally. E.g.:

% echo $(env |wc -c)
4392


Odd: ulimit -n gives 1024, grep OPEN_MAX limits.h gives 256. Also
grep LINK_MAX limits.h gives 127 but I can create more.

Some of those limits are dynamically (run-time) configurable. ARG_MAX
apparently is not.


And I believe there's also a maximum size to the number of
pointers in the array char *argv[].

Couldn't find that one ...

I don't think there is one, but I'm not 100% sure about that.


Wolfgang


Randall Schulz
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >