From: Michal Suchanek Date: 2008-08-21T16:50:51+09:00 Subject: [ruby-core:18361] Ruby popen bug #1, isolated Hello It looks like the problems with IO.popen I see have multiple causes, and the fact that repeatedly calling popen fails is not in itself enough to isolate a particular problem. However, I was trying to put my code into a shape that would work on JRuby at least, and found a test that reproducibly fails on ~100 iterations for me. With this test I get EBADF on ruby 1.8.5 after 107 iterations and on 1.8.7 anfter 104 iterations, always. Since I got a version of the code that hopefully works for me I guess I won't look into the other problems any time soon. Thanks Michal ruby 1.8.5 (2006-08-25) [x86_64-linux] ruby 1.8.7 (2008-06-20 patchlevel 22) [x86_64-linux] def try_analyze *words analyzer = IO.popen( 'cat', IO::RDWR ) res = [] t = Thread.new( (IO::for_fd analyzer.fileno),res){|fd,ary| while l = fd.gets do STDERR.putc 8 ary.push l end fd.close rescue nil # hopefully prevents zombie hordes } words.each{|w| STDERR.putc '.'[0] analyzer.puts w } analyzer.close_write rescue nil t.join end 1.upto(10000){|_| try_analyze *%w(a b c d e f g h i) STDERR.puts _ }