Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I work in company writing Audio Plugins for various programs, and currently I have the following problem with Logic on Os X Mavericks and Yosemite. Logic scans all our plugins, and, at some point it can no longer access the files. The errno is 24, meaning "Too Many Open Files"

We have the following roows in our code, that increase file descriptors available:

struct rlimit limit;
if (::getrlimit(RLIMIT_NOFILE, &limit) == 0)
    limit.rlim_cur = (in_maxOpenFiles);
    setrlimit(RLIMIT_NOFILE, &SetLimit);

And I also tried:

struct rlimit limit;
if (::getrlimit(RLIMIT_NOFILE, &limit) == 0)
    limit.rlim_cur = (in_maxOpenFiles);
    limit.rlim_max = (in_maxOpenFiles);
    setrlimit(RLIMIT_NOFILE, &SetLimit);

Yet it did not help. The funny thing is, that if I open terminal, and run the following command:

ulimit -n 1024

and then I run the Logic from WITHIN the terminal everything is fine and there is no descriptor problems!!

Now, I thought that setrlimit is suppose to do the same as setrlimit, no? What am I doing wrong?

P.S. I also tried this solution: https://unix.stackexchange.com/questions/108174/how-to-persist-ulimit-settings-in-osx-mavericks

It did not help.

Yes. Didn't work. I guess calling it from within application is too late. It does not affect already running process. – Iron-Eagle Jun 29, 2015 at 12:38 Have you tried examining the return value of setrlimit? (I think there's a typo in "setrlimit is suppose to do the same as setrlimit" but I'm unable to guess what it is.) – molbdnilo Jun 29, 2015 at 12:54

I found the solution to my problem in this article eventually: http://docs.basho.com/riak/latest/ops/tuning/open-files-limit/#Mac-OS-X

Here is also solution (For Maverick, not Yosemite): https://unix.stackexchange.com/questions/108174/how-to-persist-ulimit-settings-in-osx-mavericks

However, it is still unclear why setrlimit fails. Probably OS X bug (Or feature).

The code above (1st variant) doesn't fail if there is no 3rd party software messing around w/ ulimit, launchctl limit maxfiles, etc. Reboot your mac and try again.

P.S. Let's not multiply such software P.P.S check 'errno' variable for error code

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.