ulimit -n 可设置的最大值是多少?
直接看源码吧
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#define __const_min(x, y) ((x) < (y) ? (x) : (y))
// 64位机
#define BITS_PER_LONG 64
int main(int argc, char *argv[])
{
int sysctl_nr_open_max = __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG;
printf("The value of INT_MAX = %d\n", INT_MAX);
printf("The value of INT_MIN = %d\n", INT_MIN);
printf("The value of ulimit = %d\n", sysctl_nr_open_max);
// printf("~0 = %ud\n", (~(size_t)0)/sizeof(void *));
// printf("-1 = %ud\n", (2*INT_MAX)+1);
// printf("test = %d\n", (INT_MAX & -BITS_PER_LONG));
return 0;
}