What is the maximum length of command line arguments in gnome-terminal?
... and is there a system environment variable which reports this value?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityWhat is the maximum length of command line arguments in gnome-terminal?
... and is there a system environment variable which reports this value?
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
xargs
isn't just for reporting the limit, it's also (primarily) for working around it — see the man page or other documentation.
Nov 19, 2010 at 22:57
xargs --show-limits --no-run-if-empty < /dev/null 2>&1 |sed -n "/could actually use/s/.*: \\([0-9]\+\\)/\1/p"
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));
I don't really know about gnome-terminal, but the shell has not a 'fixed' limit, but the limit of the stack.
However there is an hardcode limit per-argument that is 128KB, that should not be a problem if you don't use 'very very very long arguments....'.
You can read more about this here: