From: Edd Barrett Date: 2008-03-06T09:37:36+09:00 Subject: Re: Too many open files on OpenBSD Edd Barrett wrote: > ---8<--- > ./tlpsrcnode.rb:19:in `initialize': Too many open files - > /home/tl/tl/Master/tlpkg/tlpsrc/wordcount.tlpsrc (Errno::EMFILE) > from ./tlpsrcnode.rb:19:in `new' > from ./tlpsrcnode.rb:19:in `parse' > from ./tlpsrcnode.rb:30:in `parse' > from ./tlpsrcnode.rb:20:in `each' > from ./tlpsrcnode.rb:20:in `parse' > from ./tlpsrcnode.rb:30:in `parse' > from ./tlpsrcnode.rb:20:in `each' > from ./tlpsrcnode.rb:20:in `parse' > ... 3055 levels... > from ./tlpsrcnode.rb:20:in `each' > from ./tlpsrcnode.rb:20:in `parse' > from ./roottlpsrcnode.rb:53:in `startParse' > from ./rbmfsplit:54 > ---8<--- > > This appears to happen after 297 files are concurrently opened. Sorry this statement is inaccurate. 297 files have previously been opened and after each one has been parsed is immediately closed. The call stack should be an indication of concurrently opened files? In this case 5 files. (Its recursive). i suppose the src of the parse function helps (probably disobeying all coding conventions, sorry): ---8<--- def parse() fileHandle = File.new @path for line in fileHandle do line =~ /^(.*?) (.*)/ cmd = $~[1] arg = $~[2] if cmd =~ /^#.*/ then nil # comment elsif cmd == "depend" then newNode = TlpSrcNode.new @basePath + arg + ".tlpsrc", @rootNode newNode.parse # and so recursion starts @rootNode.incrementDeps elsif cmd == "runpattern" then @rootNode.addRunFile arg elsif cmd == "docpattern" then @rootNode.addDocFile arg elsif cmd == "srcpattern" then @rootNode.addSrcFile arg elsif @nothingCmds.detect { |i| i == cmd } then nil # OK elsif @todoCmds.detect { |i| i == cmd } then nil # XXX work out what these are else puts "*error: unknown cmd: '#{cmd}' arg='#{arg}'" exit 1 end end fileHandle.close end ---8<--- -- Posted via http://www.ruby-forum.com/.