每个进程最大打开文件数 [英] Max open files per process

查看:135
本文介绍了每个进程最大打开文件数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac OS X(10.6)中,每个进程最大打开文件数是多少?

What is a maximum open files count in Mac OS X (10.6) per process?

ulimit表示大于256,sysctl表示10240,但是我的测试程序可以创建9469(在gdb下),10252(无gdb)文件..

ulimit said than 256, sysctl said 10240, but my test program can create 9469 (under gdb), 10252 (without gdb) files..

推荐答案

现在很清楚.

ulimit命令是在Shell中构建的.您可以使用ulimit -n命令为当前shell(以及从该shell启动的每个程序)设置maxfiles.

The ulimit command is build in shell. You can set the maxfiles using ulimit -n command for current shell (and every program which was started from this shell).

10252个文件-这是我的错误..从外壳启动测试程序时,它最多打开了253个文件(253 + stdin + stdout + stderr = 256).

10252 files - it was my mistake.. it was 253 max open files when I start my test program from shell (253 + stdin + stdout + stderr = 256).

9469文件-我的测试程序在Xcode下运行的结果,看来Xcode在运行该程序之前先设置了maxfiles.

9469 files - the result of my test program running under Xcode, it seems that Xcode set tha maxfiles before running the program.

ulimit不是系统范围的设置,这就是为什么要为maxfiles设置系统范围的值的原因,您必须使用launchctl(系统中的第一个进程,尝试对"launchctl limit"进行启动)或sysctl.

ulimit is not system wide setting, thats why to set the system wide value for maxfiles you must use launchctl (the first process in the system, try to 'launchctl limit') or sysctl.

答案是256个文件.

这篇关于每个进程最大打开文件数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆