我使用的命令是:ulimit -n,我得到的数字是1024,这是我系统中每个进程打开文件的最大数量。但是通过下面的程序我可以看到数字510 ......?出了什么问题Linux中每个进程打开的文件的最大数量
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
int main(void)
{
int pipe_ext = 0, pfd[ 2 ], counter = 0;
while (1)
{
pipe_ext = pipe(pfd);
//errno = 0;
if (pipe_ext == 0)
{
write(pfd[ 1 ], "R", 1);
counter = counter + 1;
printf("Counter = %d\n", counter);
}
else
{
perror("pipe()");
printf("errno = %d\n", errno);
exit(1);
}
}
return(0);
}
它不是一个真正的文件,进程的最大数目,它的文件描述符的最大数量,这可能是从管什么开放网络套接字。 – John