Diego Bernardes
Diego Bernardes

Reputation: 179

How to increase quantity of file descriptors on MacOS Mojave?

Can't find a way to do this, every version of MacOS use a different version and Mojave still very recent, so can't find anything.

Upvotes: 1

Views: 1933

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90521

Programmatically, you can use getrlimit() and setrlimit() to adjust the number of file descriptors the process can open. The relevant resource identifier is RLIMIT_NOFILE.

As noted in the man page, RLIMIT_NOFILE works somewhat differently than other resources. getrlimit() might indicate that the hard limit is RLIM_INFINITY (unlimited), but the kernel actually imposes a limit of OPEN_MAX (currently 10240). So, treat that as the maximum that you can set using setrlimit().

To do this for a program whose code you don't control, you can adjust the limit in a shell before launching that program from that shell. In bash and other sh-derived shells, you can use the ulimit built-in command for that. For example, ulimit -Sn 10240.

Upvotes: 2

Related Questions