1. size of argument list can be larger than ARG_MAX?
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");
2. NIS problem
3. Increasing ARG_MAX
4. solaris 2.6 kernel patch fails..
5. ARG_MAX
6. dumping NIS+
7. The ARG_MAX kernel value
8. Ramen hits NASA
9. max size of arguments can be >, =, < ARG_MAX, a bug?
10. Q: xargs & LINE_MAX/ARG_MAX
11. Change the value of ARG_MAX
12. Why does the cgi environment not inherit environment variables?
13. how to export shell environment variables to the primary environment?