diff options
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | lib/facter/util/resolution.rb | 5 | ||||
-rwxr-xr-x | spec/unit/util/resolution.rb | 11 |
3 files changed, 18 insertions, 0 deletions
@@ -1,4 +1,6 @@ 1.5.x: + Added a Process.waitall thread when there's a timeout, to avoid zombies. + Set the timeout the host-based and resolve-based resolutions to 2. Fixed #1495 - CentOS version detection is now better. diff --git a/lib/facter/util/resolution.rb b/lib/facter/util/resolution.rb index 19f2c1e..b50c9e9 100644 --- a/lib/facter/util/resolution.rb +++ b/lib/facter/util/resolution.rb @@ -121,6 +121,11 @@ class Facter::Util::Resolution end rescue Timeout::Error => detail warn "Timed out seeking value for %s" % self.name + + # This call avoids zombies -- basically, create a thread that will + # dezombify all of the child processes that we're ignoring because + # of the timeout. + Thread.new { Process.waitall } return nil end diff --git a/spec/unit/util/resolution.rb b/spec/unit/util/resolution.rb index 5ce3d63..643be33 100755 --- a/spec/unit/util/resolution.rb +++ b/spec/unit/util/resolution.rb @@ -112,6 +112,17 @@ describe Facter::Util::Resolution do @resolve.value.should be_nil end + + it "should waitall to avoid zombies if the timeout is exceeded" do + @resolve.stubs(:warn) + @resolve.timeout = 0.1 + @resolve.setcode { sleep 2; raise "This is a test" } + + Thread.expects(:new).yields + Process.expects(:waitall) + + @resolve.value + end end end |