As I understand
The size of environment variable and the size of argument list, i.e.
strlen(envp[0]) + strlen(envp[1]) + .. + strlen(argv[0]) + strlen(argv[1]) + ..
can not be larger than ARG_MAX, which is 1048320 on Solaris.
By using env -i, none of environment variables are used, so
the size of argument list can not be larger than ARG_MAX,
which is 1048320 on Solaris.
However the following example can be compiled and run with
env -i ./a.out
And this shows that the size of argument list can be
1048355+6=1048461. What is the matter?
I run different tests, and all show that the size of argument list can be
larger than ARG_MAX, but how much larger is different.
Please help me to understand this issue, thanks.
#include <stdlib.h>
#include <string.h>
#ifndef _ARG_MAX
#define _ARG_MAX 1048355
#endif
int
main(int argc, char **argv, char **envp)
{
char *arg = malloc((size_t) _ARG_MAX);
memset(arg, ' ', _ARG_MAX);
execlp("/bin/ls", arg, '\0');
perror("exec");
Quote:}