返回信息流非递归遍历文件夹,用的队列
在读到某个文件夹时在readdir(path)处吐核了
比如在文件夹/home/1下面有1-1,1-2,1-3...1-2015这些文件夹,在读到1-1000时挂掉,然后尝试删除文件夹下1-1文件夹后,就会在读到1-1001处挂掉
可能会是什么原因???
这是一条镜像帖。来源:北邮人论坛 / cpp / #89561同步于 2015/11/29
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
readdir函数莫名其妙挂掉
chenxiansf
2015/11/29镜像同步8 回复
订阅后,新回复会通过你的通知中心匿名送达。
8 条回复
处理顺序应该是 1-1、1-10、1-100、1-1000、1-1001 。。。
所以可能只处理了几个文件而已吧,在第4个出错。
你是说core了吗,那可以贴出出错原因,或者贴代码
代码已上。
处理的文件和文件夹非常多
【 在 inaadversity 的大作中提到: 】
: 处理顺序应该是 1-1、1-10、1-100、1-1000、1-1001 。。。
: 所以可能只处理了几个文件而已吧,在第4个出错。
: 你是说core了吗,那可以贴出出错原因,或者贴代码
opendir()
// ...
closedir()?
man 3 readdir: d_type
On Linux, the dirent structure is defined as follows:
struct dirent {
ino_t d_ino; /* inode number */
off_t d_off; /* offset to the next dirent */
unsigned short d_reclen; /* length of this record */
unsigned char d_type; /* type of file; not supported
by all file system types */
char d_name[256]; /* filename */
};
还是没贴出core的报错信息。。。
为什么只有opendir没有closedir?
ulimit -n 看看是不是1000?
如果不是的话,调试下core文件。
啊啊啊,没有写closedir,多谢多谢
【 在 BTup 的大作中提到: 】
: opendir()
: // ...
: closedir()?
: ...................
不知道怎么找core报错的信息。
的确是因为没有closedir的原因。
太感谢了
【 在 inaadversity 的大作中提到: 】
: 还是没贴出core的报错信息。。。
: 为什么只有opendir没有closedir?
: ulimit -n 看看是不是1000?
: ...................
一个小建议
readdir可换为scandir
readdir不保证读的顺序
可能会变
之前被坑过一次
scandir可自定义filter, compare
很好用
学习了,非常感谢!
【 在 guo (计忆邮心|郭) 的大作中提到: 】
: 一个小建议
: readdir可换为scandir
: ...................