From fc9f845dc5e91c19008781b4cbb5d42eb1d1e669 Mon Sep 17 00:00:00 2001 From: sersut Date: Tue, 16 Apr 2013 09:35:07 -0700 Subject: Clean inherited file descriptors from the parent while forking subprocess. --- spec/mixlib/shellout_spec.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'spec/mixlib') 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 } } -- cgit v1.2.1