如果进程数大于 pid_max 会发生什么情况?

如果进程数大于 pid_max 会发生什么情况?

假设我不编辑文件:/proc/sys/kernel/pid_max。因此,我假设最大 PID 为 32768。

如果我创建 32769 个同时进程会发生什么情况?

答案1

man forkOS X(以及一般基于 BSD 的系统)开始:

ERRORS
 Fork() will fail and no child process will be created if:

 [EAGAIN]    The system-imposed limit on the total number of processes under
             execution would be exceeded.
             This limit is configuration-dependent.

 [EAGAIN]    The system-imposed limit MAXUPRC (<sys/param.h>) on the total number
             of processes under execution by a single user would be exceeded.

 [ENOMEM]    There is insufficient swap space for the new process.

相关内容