可能导致这种情况的原因是什么?
opendir(my $dh, $tdir) or die "Could not open temp dir: $!";
for my $file (readdir($dh)) {
print STDERR "checking file $tdir/$file\n";
next unless -e "$tdir/$file";
print STDERR "here's the file for $tdir/$file: ";
print STDERR `cat $tdir/$file`;
die "Not all files from hub '$hid' have been collected!: $tdir/$file";
}
输出:
checking file
/tmp/test2~22363~0G0Tjv/22363~0~4~22380~0~1~Test2~Event~Note
here's the file for /tmp/test2~22363~0G0Tjv/22363~0~4~22380~0~1~Test2~Event~Note:
cat: /tmp/test2~22363~0G0Tjv/22363~0~4~22380~0~1~Test2~Event~Note: No such file or directory
IPC Fatal Error: Not all files from hub '22363~0~4' have been collected!:
我意识到理论上其他一些进程或线程可能在循环之间踩到我的文件,但这是Perl(单线程)和Test2 / Test :: Simple的测试目录,应限于由主流程管理。
带给我的是我在其他代码中看到过类似的错误:
if(-e $cachepath) {
unlink $cachepath
or Carp::carp("cannot unlink...
引发"无法取消链接..."
也
$cache_mtime = (stat($cachepath))[_ST_MTIME];
....
if ($cache_mtime){
open my($in), '<:raw', $cachepath
or $self->_error("LoadError: Cannot open $cachepath for reading:
抛出&#34; LoadError:无法打开...&#34;例外
那些也应该只有一个进程在目录上运行的情况,这一切都让我怀疑还有什么事情发生。
这是Linux内核,完全与供应商补丁保持同步。
答案 0 :(得分:1)
事实证明这确实是儿童过程和竞争条件。 Test :: Simple中的较新代码不适用于嵌套子测试。无论如何,感谢允许我排除一些我不知道的模糊文件系统。