summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mixlib/shellout/unix.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb
index af3e421..d7b8b92 100644
--- a/lib/mixlib/shellout/unix.rb
+++ b/lib/mixlib/shellout/unix.rb
@@ -82,10 +82,18 @@ module Mixlib
end
end
self
- rescue Exception
- # do our best to kill zombies
+ 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
+ # 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
# no matter what happens, turn the GC back on, and hope whatever busted
# version of ruby we're on doesn't allocate some objects during the next