Which command controls the open file limits?
The simple answer used to be that there were multiple limits and the lowest limit that you reach in a specific instance will generate your error. Now on 10.12 launchctl limit maxfiles is also in the mix. For details on implementation, this great answer is getting bounty and deserves more votes than the one I can give it.

other relevant threads are:


`ulimit -n` for non-root
Why won&#39;t kern.maxfiles setting in /etc/sysctl.conf stick?


The ulimit level is set low to prevent one poor shell script from flooding the kernel with open files.

The kern.maxfilesperproc is there to leave a little room in the max files count so that one process can use most but not all of the open file handler space from the kernel.

For normal situations, the kern.maxfiles is the final limiting factor.

On Sierra - the limits are 256 open files and unlimited max, so I'm finding that having 3 to 4 thousand files set for the soft limit works for just about all our hardware and still keeps the system responsive when a runaway process opens too many files. We do like to keep our development servers at the 256 limit so that we catch leaky and problematic software in development / staging and test rather than finding out about it in production.


http://krypted.com/mac-os-x/maximum-files-in-mac-os-x/


I'm not a fan of 10k files - maybe with APFS and NVMe storage we will see the day when that's not unthinkable, but try to stick with hundreds or low thousands for your file limits. Especially if your mac has a low process limit, having so many files opened by so few processes can be problematic.