From e1d1d363ae4c2338726a1acaa3aafe1abaadbe82 Mon Sep 17 00:00:00 2001 From: equivalence1 Date: Wed, 9 Nov 2016 15:40:01 +0300 Subject: [PATCH] better handling of int signal. --- bin/gdb_wrapper | 10 +++++++--- lib/ruby-debug-ide/attach/native_debugger.rb | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/gdb_wrapper b/bin/gdb_wrapper index 0f0709d..c89bd8d 100755 --- a/bin/gdb_wrapper +++ b/bin/gdb_wrapper @@ -81,11 +81,15 @@ require 'ruby-debug-ide/attach/process_thread' debugger = choose_debugger(options.ruby_path, options.pid, options.gems_to_include, debugger_loader_path, argv) trap('INT') do - unless debugger.pipe.closed? + unless debugger.exited? $stderr.puts "backtraces for threads:\n\n" - debugger.process_threads.each do |thread| - $stderr.puts "#{thread.thread_info}\n#{thread.last_bt}\n\n" + process_threads = debugger.process_threads + if process_threads + process_threads.each do |thread| + $stderr.puts "#{thread.thread_info}\n#{thread.last_bt}\n\n" + end end + debugger.exit end exit! end diff --git a/lib/ruby-debug-ide/attach/native_debugger.rb b/lib/ruby-debug-ide/attach/native_debugger.rb index e0a8c1c..05ea9d9 100644 --- a/lib/ruby-debug-ide/attach/native_debugger.rb +++ b/lib/ruby-debug-ide/attach/native_debugger.rb @@ -118,8 +118,11 @@ def load_debugger end + def exited? + @pipe.closed? + end + def exit - execute 'q' @pipe.close end