Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Following ARG_MAX, maximum length of arguments for a new process it seems like ARG_MAX is wrongly (or at least ambiguously) defined on my Mac Mini 3,1 running Ubuntu 12.04:

$ getconf ARG_MAX # arguments 
$ locate limits.h | xargs grep -ho 'ARG_MAX[ \t]\+[0-9]\+' | uniq | cut -d ' ' -f 8

The actual limit seems to be somewhere between these:

$ cd "$(mktemp -d)"
$ touch $(seq 1 131072) && find . -mindepth 1 -printf x | wc -c && rm *
$ touch $(seq 1 131073) && find . -mindepth 1 -printf x | wc -c && rm *
$ touch $(seq 1 $(getconf ARG_MAX)) && find . -mindepth 1 -printf x | wc -c && rm *
bash: /usr/bin/touch: Argument list too long

I did a small search:

cd "$(mktemp -d)"
while true
    search=$((min + (max - min) / 2))
    if touch $(seq 1 $search) 2>/dev/null
    [[ $((max - min)) -le 1 ]] && echo "ARG_MAX = $min" && break

Eventually this resulted in ARG_MAX = 314290, which doesn't seem to have any relation to either of the ARG_MAX values found before. Is this normal? Is there a simpler way to find the actual ARG_MAX?

Did I misunderstand the definition of ARG_MAX? It seems it's actually the byte (or possibly character) length of the arguments with or without (?) the separating spaces. If it's really the byte length, are there also other restrictions?

share|improve this question
up vote 4 down vote accepted

Yes, it's the length in bytes, including the environment.

Very roughly:

$ { seq 1 314290; env; } | wc -c

linux sysconf

The maximum length of the arguments to the exec(3) family of functions. Must not be less than _POSIX_ARG_MAX (4096).

POSIX 2004 limits.h

Maximum length of argument to the exec functions including environment data. Minimum Acceptable Value: {_POSIX_ARG_MAX}

share|improve this answer

The page that you linked to about ARG_MAX states that as of kernel version 2.6.23 it is 1/4th the stack size. It even links to the git commit responsible.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.