> On 25 Jul 2025, at 10:01, Guy Harris <[email protected]> wrote: > > On Jul 24, 2025, at 8:51 AM, Hans Åberg via austin-group-l at The Open Group > <[email protected]> wrote: > >> I suggested a general form, which should allow one to experiment with C++ >> types: >> template<class Arg, class Env> >> int main(Arg args, Env envs); >> where Arg, Env are types T with constructors of the form >> T(char** first, char** last) > > A change to the signature of main() will not necessarily make any difference. > > The exec calls ultimately, on most implementations, will involve a system > call that will copy the argument and environment strings into a buffer in the > OS kernel and, when constructing the environment for the new program, copy > those things back to userland. This is independent of the language in which > the code making an exec call or the language in which main() in the new > program is written. > > In those cases, the kernel usually places a limit on the number of bytes of > data that may be copied; that limit is the ARG_MAX limit. > > Changing the signature of main() will not affect the code that imposes that > limit or the limit that it imposes. > > This is a limit on the *total* length of *all* the arguments being passed to > the program. That obviously imposes a limit on the length of any > *individual* argument, but it's not as if you can pass an unlimited number of > strings, each of which has a separate limit applied to it; the limit is on > the *sum* of the length of *all* the arguments, so if, for example, the first > argument reaches the limit, no more arguments can be passed after that.
The OS can make a single allocation and mark out the C-strings with terminating null characters. >From my point of view, I just try to make C++ programming within the program >more convenient, not affecting this at all. But the question was raised about these large arguments that people do use. Perhaps there should be some other mechanism to handle that.
