From 34c89dff6a872cc4d426f78aa2715af354ad1305 Mon Sep 17 00:00:00 2001 From: kaustubh-d Date: Mon, 25 Aug 2014 15:47:45 +0530 Subject: clean_parent_file_descriptors can be achieve with close_others flag to exec method, aix removed method was slow. --- lib/mixlib/shellout/unix.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb index be2e66a..2456f49 100644 --- a/lib/mixlib/shellout/unix.rb +++ b/lib/mixlib/shellout/unix.rb @@ -318,7 +318,7 @@ module Mixlib set_cwd begin - command.kind_of?(Array) ? exec(*command) : exec(command) + command.kind_of?(Array) ? exec(*command, :close_others=>true) : exec(command, :close_others=>true) raise 'forty-two' # Should never get here rescue Exception => e -- cgit v1.2.1 From 4c88754529539a2f80260094e81863aab03bb857 Mon Sep 17 00:00:00 2001 From: kaustubh-d Date: Mon, 25 Aug 2014 16:01:21 +0530 Subject: remove #clean_parent_file_descriptors which is not required now. --- lib/mixlib/shellout/unix.rb | 27 --------------------------- spec/mixlib/shellout_spec.rb | 14 -------------- 2 files changed, 41 deletions(-) diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb index 2456f49..f93d2e5 100644 --- a/lib/mixlib/shellout/unix.rb +++ b/lib/mixlib/shellout/unix.rb @@ -211,31 +211,6 @@ module Mixlib STDIN.sync = true if input end - # When a new process is started with chef, it shares the file - # descriptors of the parent. We clean the file descriptors - # coming from the parent to prevent unintended locking if parent - # is killed. - # NOTE: After some discussions we've decided to iterate on file - # descriptors upto 256. We believe this is a reasonable upper - # limit in a chef environment. If we have issues in the future this - # number could be made to be configurable or updated based on - # the ulimit based on platform. - def clean_parent_file_descriptors - # Don't clean $stdin, $stdout, $stderr, process_status_pipe. - 3.upto(256) do |n| - # We are checking the fd for error pipe before attempting to - # create a file because error pipe will auto close when we - # try to create a file since it's set to CLOEXEC. - if n != @process_status_pipe.last.to_i - begin - fd = File.for_fd(n) - fd.close if fd - rescue - end - end - end - end - def configure_parent_process_file_descriptors # Close the sides of the pipes we don't care about stdin_pipe.first.close @@ -309,8 +284,6 @@ module Mixlib configure_subprocess_file_descriptors - clean_parent_file_descriptors - set_group set_user set_environment diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index ff493c2..dca66ae 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -1318,19 +1318,5 @@ describe Mixlib::ShellOut do end end end - - describe "#clean_parent_file_descriptors", :unix_only do - # test for for_fd returning a valid File object, but close - # throwing EBADF. - it "should not throw an exception if fd.close throws EBADF" do - fd = double('File') - fd.stub(:close).at_least(:once).and_raise(Errno::EBADF) - File.should_receive(:for_fd).at_least(:once).and_return(fd) - shellout = Mixlib::ShellOut.new() - shellout.instance_variable_set(:@process_status_pipe, [ 98, 99 ]) - lambda { shellout.send(:clean_parent_file_descriptors) }.should_not raise_error - end - end - end end -- cgit v1.2.1 From 00cff06778607caf6abf7783d276f441af00237e Mon Sep 17 00:00:00 2001 From: kaustubh-d Date: Wed, 27 Aug 2014 17:16:17 +0530 Subject: update travis for ruby version support. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4cc49e0..02a71ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ rvm: - - 1.8.7 - 1.9.3 - 2.0.0 + - 2.1.2 branches: only: -- cgit v1.2.1