C中进程链中的最大子进程数

Maximum number of childs in a chain of processes in C

使用c可以在进程链中创建的最大进程数是多少?

我正在使用 Ubuntu 18.04。和 gnu-90 编译器。是否有一个变量包含在流程链中可以创建多少个流程? 如果我无法再在链中创建新进程,我该如何处理错误?

Which is the maximum number of processes that can be created in a process chain using c?

用户可以创建的进程数有限制:

[max@supernova:~] $ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"

[max@supernova:~] $ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 128103
max locked memory       (kbytes, -l) 8589934592
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8515
cpu time               (seconds, -t) unlimited
max user processes              (-u) 128103 <---------------- here
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

请注意,最大用户进程数 只是一个限制而非要求,您的系统可能 运行 在您能够创建那么多进程之前内存不足。