running in a tight loop. If I let it run for a short time (about 25
seconds), I get this error:
Enter URL: ./dice.rb:89:in `popen': Too many open files - /usr/bin/xclip -o (Errno::EMFILE)
from ./dice.rb:89:in `read'
from ./dice.rb:181
from ./dice.rb:162:in `loop'
from ./dice.rb:162
I don't understand the nature of the error, since the pipe is implicitly
closed when the block exits, right? Event if I change the line to:
running in a tight loop. If I let it run for a short time (about 25
seconds), I get this error:
Enter URL: ./dice.rb:89:in `popen': Too many open files - /usr/bin/xclip -o (Errno::EMFILE)
from ./dice.rb:89:in `read'
from ./dice.rb:181
from ./dice.rb:162:in `loop'
from ./dice.rb:162
I don't understand the nature of the error, since the pipe is implicitly
closed when the block exits, right? Event if I change the line to:
I still have the same problem. So, what file resource is being consumed,
and how do I fix it?
read carefully - you've given the block to readlines - not popen. invert your logic
IO.popen(cmd) do |pipe|
pipe.readlines{|line| print line}
end
--
"Oh, look: rocks!"
-- Doctor Who, "Destiny of the Daleks"
-a
···
On Jun 5, 2007, at 1:02 PM, Todd A. Jacobs wrote:
--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama