There are much easier ways to do this rather than via experimentation.
Most Unix systems provide ulimit
to show you the various soft (ie. user defined) and hard (ie. admin defined) limits on your account. For example, here's my soft and hard limits on OS X.
$ ulimit -a -S
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited
$ ulimit -a -H
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) unlimited
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 65532
cpu time (seconds, -t) unlimited
max user processes (-u) 1064
virtual memory (kbytes, -v) unlimited
While the system may support more processes, your program will be limited by these limits. I am limited to 709 (what an odd number) processes and can raise it to 1064.
The maximum number of processes at a single time is limited by the size of pid_t
and often by a restriction defined in the kernel. See this answer and also this answer for more detail.