Last active
March 5, 2017 13:09
-
-
Save floehopper/3ee80293e8fee340f0db816977a9b2e9 to your computer and use it in GitHub Desktop.
Ruby Dir.glob returns empty array when too many open files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir /tmp/ruby-dir-glob-returns-empty-array-when-too-many-open-files | |
$ cd /tmp/ruby-dir-glob-returns-empty-array-when-too-many-open-files | |
$ touch foo | |
$ ulimit -n 16 | |
$ ruby -e "1.upto(16).map { |i| p [i, Dir.glob('*')]; File.new('foo') }" | |
[1, ["foo"]] | |
[2, ["foo"]] | |
[3, ["foo"]] | |
[4, ["foo"]] | |
[5, ["foo"]] | |
[6, ["foo"]] | |
[7, ["foo"]] | |
[8, ["foo"]] | |
[9, ["foo"]] | |
[10, []] # Dir.glob returns empty array and does not raise exception | |
-e:1:in `initialize': Too many open files @ rb_sysopen - foo (Errno::EMFILE) | |
from -e:1:in `new' | |
from -e:1:in `block in <main>' | |
from -e:1:in `upto' | |
from -e:1:in `each' | |
from -e:1:in `map' | |
from -e:1:in `<main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir /tmp/ruby-dir-new-raises-exception-when-too-many-files-open | |
$ cd /tmp/ruby-dir-new-raises-exception-when-too-many-files-open | |
$ touch foo | |
$ mkdir bar | |
$ ulimit -n 16 | |
$ ruby -e "1.upto(16).map { |i| p [i, Dir.new('bar')]; File.new('foo') }" | |
[1, #<Dir:bar>] | |
[2, #<Dir:bar>] | |
[3, #<Dir:bar>] | |
[4, #<Dir:bar>] | |
[5, #<Dir:bar>] | |
[6, #<Dir:bar>] | |
[7, #<Dir:bar>] | |
[8, #<Dir:bar>] | |
[9, #<Dir:bar>] | |
-e:1:in `initialize': Too many open files @ dir_initialize - bar (Errno::EMFILE) | |
from -e:1:in `new' | |
from -e:1:in `block in <main>' | |
from -e:1:in `upto' | |
from -e:1:in `each' | |
from -e:1:in `map' | |
from -e:1:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ruby bug reported: https://bugs.ruby-lang.org/issues/13276