summaryrefslogtreecommitdiff
path: root/lib/mixlib/shellout/unix.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-09-11 11:50:31 -0700
committerdanielsdeleo <dan@opscode.com>2013-09-11 11:50:31 -0700
commite986fc3ea9d0a6f09c005e7240db60b4db2861a7 (patch)
treed332fb8ac53c3d14e8e8aae5bcaf115309630f1b /lib/mixlib/shellout/unix.rb
parentfd66077d0368babc5ba57d52f96e1ebc52d70ca1 (diff)
parentebe7f8e87349655ba2601a3b18c4711fd95c6bf5 (diff)
downloadmixlib-shellout-e986fc3ea9d0a6f09c005e7240db60b4db2861a7.tar.gz
Fix MIXLIB-17
Diffstat (limited to 'lib/mixlib/shellout/unix.rb')
-rw-r--r--lib/mixlib/shellout/unix.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb
index 55a0372..d7b8b92 100644
--- a/lib/mixlib/shellout/unix.rb
+++ b/lib/mixlib/shellout/unix.rb
@@ -82,8 +82,16 @@ module Mixlib
end
end
self
+ rescue Errno::ENOENT
+ # When ENOENT happens, we can be reasonably sure that the child process
+ # is going to exit quickly, so we use the blocking variant of waitpid2
+ Process.waitpid2(@child_pid) rescue nil
+ raise
rescue Exception
- # do our best to kill zombies
+ # For exceptions other than ENOENT, such as timeout, we can't be sure
+ # how long the child process will live, so we use the non-blocking
+ # variant of waitpid2. This can result in zombie processes when the
+ # child later dies. See MIXLIB-16 for proposed enhancement.
Process.waitpid2(@child_pid, Process::WNOHANG) rescue nil
raise
ensure