Max open files per process

2019-03-17 01:58发布

问题:

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

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

回答1:

It is clear now.

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 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 files - the result of my test program running under Xcode, it seems that Xcode set tha maxfiles before running the program.

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.

And the answer is 256 files.