diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index ae314879371..9659ca97f01 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -723,6 +723,24 @@ def bin_path(a,b,c) expect(out).to eq("foo") end end + + context "signals not being trapped by bunder" do + let(:executable) { strip_whitespace <<-RUBY } + #{shebang} + + signals = "#{test_signals.join(', ')}".split(', ') + result = signals.map do |sig| + Signal.trap(sig, "IGNORE") + end + puts result.select { |ret| ret == "IGNORE" }.count + RUBY + + it "makes sure no unexpected signals are restored to DEFAULT" do + bundle("exec #{path}") + + expect(out).to eq(test_signals.count.to_s) + end + end end context "nested bundle exec" do diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 62016310111..69d72b6a624 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -217,10 +217,21 @@ def gem_command(command, args = "", options = {}) end bang :gem_command + def test_signals + open3_reserved_signals = %w[CHLD CLD PIPE] + reserved_signals = %w[SEGV BUS ILL FPE VTALRM KILL STOP EXIT] + bundler_signals = %w[INT] + + Signal.list.keys - (bundler_signals + reserved_signals + open3_reserved_signals) + end + def sys_exec(cmd) command_execution = CommandExecution.new(cmd.to_s, Dir.pwd) Open3.popen3(cmd.to_s) do |stdin, stdout, stderr, wait_thr| + test_signals.each do |n| + Signal.trap(n, "IGNORE") + end yield stdin, stdout, wait_thr if block_given? stdin.close