diff options
author | danielsdeleo <dan@getchef.com> | 2014-03-31 10:24:50 -0700 |
---|---|---|
committer | danielsdeleo <dan@getchef.com> | 2014-03-31 10:24:50 -0700 |
commit | 6faa04e8c173e5c1f029a0d378c991a9a908dc36 (patch) | |
tree | e291ec19b3cab03688274122452b068df5fdf516 /spec | |
parent | a6b9916767825b0902059e72025b7e649c61d7fd (diff) | |
download | mixlib-shellout-6faa04e8c173e5c1f029a0d378c991a9a908dc36.tar.gz |
Handle ESRCH when getting pgid of a zombie on OS X
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index 42f2714..03bb47b 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -843,6 +843,25 @@ describe Mixlib::ShellOut do end end + context "when the child process dies immediately" do + let(:cmd) { [ 'exit' ] } + + it "handles ESRCH from getpgid of a zombie" do + Process.stub(:setsid) { exit!(4) } + + # there is a small race condition here if the child doesn't get + # scheduled and call exit! before the parent can call getpgid, so run + # this a few times to make sure we've created the reproduction case + # correctly. + 5.times do + s = Mixlib::ShellOut.new(cmd) + s.run_command # should not raise Errno::ESRCH + end + + end + + end + context 'with subprocess that takes longer than timeout' do def ruby_wo_shell(code) parts = %w[ruby] |