[TriLUG] Limit to command line arguments?

Nathan Conrad conrad at bungled.net
Fri Oct 21 21:26:43 EDT 2005


>From a look at the kernel source code, you get (on i386) 128 kB of
space for the program's arguments and environmental variables. There
appears to be no set limit except this memory limit. Remember that you
will have to also take in account the space needed to store the array
of pointers to the arguments (4 byte each) and the argument count plus
a few more misc things.

So, assuming that you have no environment variables to pass to the
application, you can have up to around (128kB * 1024 kB/B) / (6
B/argument) = 21,845 arguments of zero length....

So, you get somewhere around 360 characters per argument if you want
to pass 350 of them.

On other architectures, such as MIPS, you can optionally have more
(kernel build option for page size). You might also be able to change
one of the kernel source files to increase the limit of pages that can
be used for the parameters.

-Nathan Conrad

[Though I could be misreading something. You should write a quick
program to verify these numbers]

On Fri, Oct 21, 2005 at 06:57:33PM -0400, Randy Barlow wrote:
> What is the limit on the number of command line arguments you can pass 
> to a program (assuming use of bash).  Are there other shells than bash 
> that give more?  I need to pass about 350 arguments to a program I am 
> working on, will this work?
> 
> Randy
> -- 
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/



More information about the TriLUG mailing list