How to increase the limit of “maximum open files” in C on Mac OS X

后端 未结 6 2049
刺人心
刺人心 2020-12-15 13:04

The default limit for the max open files on Mac OS X is 256 (ulimit -n) and my application needs about 400 file handlers.

I tried to change the limit with setrlimit(

6条回答
  •  無奈伤痛
    2020-12-15 13:36

    rlp.rlim_cur = 10000;

    Two things.

    1st. LOL. Apparently you have found a bug in the Mac OS X' stdio. If I fix your program up/add error handling/etc and also replace fopen() with open() syscall, I can easily reach the limit of 10000 (which is 240 fds below my 10.6.3' OPEN_MAX limit 10240)

    2nd. RTFM: man setrlimit. Case of max open files has to be treated specifically regarding OPEN_MAX.

提交回复
热议问题