linux -/proc/<pid>/limits中的Maxprocesses是否表示该进程的最大子进程数

标签 linux process

/proc//limits 中的最大进程数代表什么?

它是否表示该进程的最大子进程数?

如何在Linux运行时限制特定进程的子进程数量?

cat /proc/<pid>/limits

Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             29397                29397                processes 
Max open files            1024                 4096                 files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       29397                29397                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        

最佳答案

该数字正是您通过对 RLIMIT_NPROC 执行 getrlimit 得到的值。手册页中对此进行了描述:

The maximum number of processes (or, more precisely on Linux, threads) that can be created for the real user ID of the calling process. Upon encountering this limit, fork(2) fails with the error EAGAIN.

因此,每次您 fork 时,系统都会在允许该进程 fork 之前检查您的所有进程。如果您降低某些进程的限制 - 可能使用 shell 的 ulimit 或使用 setrlimit - 系统仍会对所有进程进行计数,但会根据新限制检查数量。

关于linux -/proc/<pid>/limits中的Maxprocesses是否表示该进程的最大子进程数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22160337/

相关文章:

linux - 暂停/禁用特定电子邮件帐户。 Linux whm cpanel

matlab - 从 matlab 中检测 matlab 进程

c - POSTFIELD 应该是什么样子的?

linux - grep 关键字后的下一行

linux - $ * * * * * echo "hi"=> blado.kdb : command not found

java - ProcessBuilder 向命令行添加额外的引号

c# - 如何在Windows中运行应用程序?

regex - 在 bash 脚本中的斜线 "/"字符前插入文本

c++ - 根据 md5 哈希阻止执行特定的 .exe 文件

.net - 如何停止从 C# .Net 应用程序启动的 Excel 进程?