What is the maximum length of command line arguments in gnome-terminal?

What is the maximum length of command line arguments in gnome-terminal?

... and is there a system environment variable which reports this value?


Solution 1:

xargs knows. On my system,

$ xargs --show-limits
Your environment variables take up 2572 bytes
POSIX upper limit on argument length (this system): 2092532
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2089960
Size of command buffer we are actually using: 131072

Solution 2:

The answer comes from the sysconf value ARG_MAX. To examine it on your system:

getconf ARG_MAX

For me, this reports 2097152. For more details check the manpage:

man sysconf

To get this inside a program, for example:

#include <unistd.h>
...
printf("%ld\n", sysconf(_SC_ARG_MAX));