summaryrefslogtreecommitdiff
path: root/lib/mixlib/shellout/unix.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-09-09 16:45:43 -0700
committerdanielsdeleo <dan@opscode.com>2013-09-09 16:45:43 -0700
commit89f7f802e3bc5ab92c32eff7f065acdebff8492c (patch)
tree676e902afb6e71fa8af832d0a3c3c2dac77785d0 /lib/mixlib/shellout/unix.rb
parent4c1e6fee46638a668e0b05914371d9271f590a86 (diff)
downloadmixlib-shellout-89f7f802e3bc5ab92c32eff7f065acdebff8492c.tar.gz
Wait for child process to die in case of critical errors
Ported the regression test from OHAI-455 to mixlib-shellout, which revealed a race condition in the way shellout reaps the child after a failed exec (most commonly caused by attempting to run a command that doesn't exist). The call to waitpid2 used WNOHANG to avoid hanging indefinitely if an error was caused but the child process was still alive, but this results in the child process not getting reaped if it exits after the call to waitpid2. In a single run of the stress test, this occurred 94/100 times, so it is very likely that mixlib-shellout will leak zombies for the ENOENT case without this change.
Diffstat (limited to 'lib/mixlib/shellout/unix.rb')
-rw-r--r--lib/mixlib/shellout/unix.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb
index 55a0372..af3e421 100644
--- a/lib/mixlib/shellout/unix.rb
+++ b/lib/mixlib/shellout/unix.rb
@@ -84,7 +84,7 @@ module Mixlib
self
rescue Exception
# do our best to kill zombies
- Process.waitpid2(@child_pid, Process::WNOHANG) rescue nil
+ Process.waitpid2(@child_pid) rescue nil
raise
ensure
# no matter what happens, turn the GC back on, and hope whatever busted