Before you change ARG_MAX to ludicrously large values: Do you understand what it does, and how it is used, and what the side-effects of the change are going to be? Please read the kernel source, and the library source for where programs get executed, and understand what really happens. I only know some small aspects of this, so I can't give you the full solution without spending several hours researching it.
Let me repeat what I just said: Please spend 4 hours studying the current design, and be ready to explain how your proposed change of a huge ARG_MAX fits into it. Your next post in this thread should be about 5 paragraphs long, and should contain a detailed design review of the existing code base.
My hunch: Once you do that, you will understand why ARG_MAX can not be very large, without creating massive performance problems. Personally, I've never liked the way all Unixes (since Dennis and Ken) have implemented passing parameters to programs, because globs are expanded too early, which makes passing parameters with globbing metacharacters harder. Why do you have to escape the star in the shell command "find . -name *.txt"? Because the shell insists in expanding *.txt; a better design would be to pass the parameters unmolested as strings to a program, and then the program could select to perform file name glob expansion where appropriate. This would in particular make things like "grep foo*bar *.txt" more logical. But alas, that is NOT the way Unixes (including FreeBSD) are designed, and we'll have to live with that.
And most importantly: Please explain to us, in considerable detail, what the real problem you are trying to solve is. In the previous thread, you said that you have very large directories, with up to 500,000 directory entries (probably files). In and of itself, directories of such size are not illegal, and much larger directories do happen on large compute clusters. I vaguely remember that one recent customer demanded that the file system be able to create 30,000 files per second, and sustain that rate. But: People who build systems of that scale understand the design of the underlying system, and adjust their usage at scale to the design. One aspect of that is: never use globbing or complete argument lists to pass a list of all directory entries; instead loop over the directory. In scripts, that is typically done with find and xargs, although more often systems at this scale write programs that use readdir() and process the result, usually in parallel on multiple computers.
For a design example, think about how iterators work in programming languages. Python is a good example: Stupid people think that a call to the range() function returns a list (of consecutive entries, like range(4) is the list [0,1,2,3]). But that's not really true. If you write the following code:
Code:
for i in range(1000000000):
do_something(i)
print('Done with one billion things.')
then the implementation is not that python creates a list of a billion integers, and then the "for" primitive runs over them. Instead range() returns an iterator, which gets called repeatedly. That is exactly the same design pattern that is used by find and xargs in scripts.
Finally, let's talk about the sociological aspects of your interaction with people here. You are demanding that people spend hours researching the kernel and exec interface, to do your homework for you. You are unwilling to spend some time changing your scripts, but expect that others invest time for you to solve your problem. And you are unwilling to give back to the community, by not contributing to a flexible solution yourself. The reason you are getting so much pushback is that you are actually being obnoxious, probably not intentionally.