summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2013-04-16 09:35:07 -0700
committersersut <serdar@opscode.com>2013-04-16 09:35:07 -0700
commitfc9f845dc5e91c19008781b4cbb5d42eb1d1e669 (patch)
treebe9cc2503aa8e36b9e08a997f695c7c08647fa8a /spec
parent6061e84ec5a1aca932746ec631ae903e89cd0f97 (diff)
downloadmixlib-shellout-fc9f845dc5e91c19008781b4cbb5d42eb1d1e669.tar.gz
Clean inherited file descriptors from the parent while forking subprocess.
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout_spec.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index 14af6e2..e4fe504 100644
--- a/spec/mixlib/shellout_spec.rb
+++ b/spec/mixlib/shellout_spec.rb
@@ -203,7 +203,7 @@ describe Mixlib::ShellOut do
context "with options hash" do
let(:cmd) { 'brew install couchdb' }
- let(:options) { { :cwd => cwd, :user => user, :domain => domain, :password => password, :group => group,
+ let(:options) { { :cwd => cwd, :user => user, :domain => domain, :password => password, :group => group,
:umask => umask, :timeout => timeout, :environment => environment, :returns => valid_exit_codes,
:live_stream => stream, :input => input } }
@@ -422,12 +422,12 @@ describe Mixlib::ShellOut do
let(:user) { 'administrator' }
let(:domain) { ENV['COMPUTERNAME'].downcase }
let(:options) { { :domain => domain, :user => user, :password => 'vagrant' } }
-
+
it "should run as Administrator" do
running_user.should eql("#{domain}\\#{user}")
end
end
- end
+ end
context "with a live stream" do
let(:stream) { StringIO.new }
@@ -762,6 +762,16 @@ describe Mixlib::ShellOut do
end
end
+ context 'with open files for parent process' do
+ let(:ruby_code) { "count = 0; 0.upto(256) do |n| fd = File.for_fd(n) rescue nil; count += 1 if fd end; puts count" }
+
+ it "should not see file descriptors of the parent" do
+ test_file = Tempfile.new('fd_test')
+ stdout.chomp.should eql("3")
+ test_file.close
+ end
+ end
+
context 'with subprocess that takes longer than timeout' do
let(:cmd) { ruby_eval.call('sleep 2') }
let(:options) { { :timeout => 0.1 } }