开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
linux
问题(Question):
出现too many open file
程式码(Code):(请善用置底文网页, 记得排版)
FILE *fp;
char bufferp[100];
while(1){
fp = popen("ls /tmp/file","r");
if (fp != NULL){
if(fgets(buffer,sizeof(buffer),fp) == NULL){
printf("no file\n");
}else
printf("have file");
}else{
perror("popen");
}
pclose(fp)
sleep(1);
}
跑大概两个小时会出现too many open file错误,但我都有正常关闭档案,为什么会出现
这种错误呢? 谢谢