<< Snow Falls Over The Trees | Home | jQuery(ing) with Lift Webframework and jQuery UI >>

OS limits for commands and arguments

in POSIX standard

There is a POSIX standard specific limitation called LINE_MAX and ARG_MAX.
First is the maximum command line length a POSIX compatible OS needs to support.
Second ist the maximum number of arguments.

Next to these limits explained in
http://opengroup.org/onlinepubs/009695399/utilities/xargs.html
the document
http://opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
tells that there "shall be no limit on the size of any shell command other than that imposed by the underlying system (memory constraints, {ARG_MAX}, and so on)."

E.g. in the document for the exec call variant execvp
http://opengroup.org/onlinepubs/009695399/functions/execvp.html
you can read:
"The number of bytes available for the new process' combined argument and environment lists is {ARG_MAX}. It is implementation-defined whether null terminators, pointers, and/or any alignment bytes are included in this total."

The environment is included in the limitation with the arguments:
"The values that the environment variables may be assigned are not restricted except that they are considered to end with a null byte and the total space used to store the environment and the arguments to the process is limited to {ARG_MAX} bytes."
[http://opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html]

In AIX you can get the maximums from the system with the getconf utility:
getconf LINE_MAX  =>    2048
getconf ARG_MAX   => 24576

You should know that there are such limitations and you should base your programs and scripts on the POSIX maximums:
_POSIX_ARG_MAX: 4096

Only POSIX provides compatibility on different Unix platforms.



Add a comment Send a TrackBack