argument list too long

Giorgos Keramidas keramida at
Wed Feb 27 11:16:24 UTC 2008

On 2008-02-27 10:16, Erik Norgaard <norgaard at> wrote:
>Wojciech Puchar wrote:
>> what is a limit of amount of arguments passed to program? is it
>> hardwired or can be changed.
>> i found it to be in order of few thousands parameteres
> searching google results in an article for linux
> gives some ideas to work arounds, the most radical to recompile the
> kernel.  Then a sysctl -a seems to indicate it is also a kernel
> limitation on FreeBSD:
> kern.argmax: 262144
> I'm not certain that this is the limit of command line arguments, and
> I  haven't tried to set it. Nor is it clear to me if this is the
> number of arguments or the number of characters in the argument
> string. In the latter case, a "few thousand" argumenst could easily
> reach that limit.

sysctl -d helps here:

$ sysctl -d kern.argmax
kern.argmax: Maximum bytes of argument to execve(2)

It is worth noting, however, that there are usually fairly easy ways to
work with huge lists of command-line arguments.  Instead of writing
things like this, for example:

	for file in *.ogg ; do
	    blah "${file}"

one can easily write:

	find . -name '*.ogg' | \
	while read file ; do \
		blah "${file}"

xargs(1) is another popular tool for processing large argument lists:

	find -name '*.ogg' | xargs blah

More information about the freebsd-questions mailing list