码迷,mamicode.com
首页 > 系统相关 > 详细

ulimit open files linux打开文件数设置验证

时间:2017-09-30 18:04:27      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:blog   文件   creat   limit   print   span   style   char   ret   

1 #include <stdio.h>
  2 #include <sys/types.h>
  3 #include <fcntl.h>
  4 #include <stdlib.h>
  5 #include <unistd.h>
  6 
  7 int main(int argc,char *argv[]){
  8 
  9     int fd;
 10     char name[1024];
 11     int i = 0;
 12     while(1){
 13         sprintf(name,"file%d",++i);
 14         fd = open(name,O_CREAT,0777); //超过最大打开数时再打开会出错,返回-1
 15         if (fd == -1){
 16             exit(1);
 17         }
 18         printf("%d ",i);
 19     }
 20     return 0;
 21 }

 

ulimit open files linux打开文件数设置验证

标签:blog   文件   creat   limit   print   span   style   char   ret   

原文地址:http://www.cnblogs.com/ruiy/p/7615510.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!