Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2008 13:15:51 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Erik Norgaard <norgaard@locolomo.org>
Cc:        Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>, freebsd-questions@freebsd.org
Subject:   Re: argument list too long
Message-ID:  <20080227111551.GA2403@kobe.laptop>
In-Reply-To: <47C52A64.5000701@locolomo.org>
References:  <20080227100132.G1831@wojtek.tensor.gdynia.pl> <47C52A64.5000701@locolomo.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2008-02-27 10:16, Erik Norgaard <norgaard@locolomo.org> 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
> 
> http://www.linuxjournal.com/article/6060
> 
> 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}"
	done

one can easily write:

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

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

	find -name '*.ogg' | xargs blah




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080227111551.GA2403>