diff --git a/lib/debug/server.rb b/lib/debug/server.rb index dfb62b4f1..53d043be7 100644 --- a/lib/debug/server.rb +++ b/lib/debug/server.rb @@ -75,13 +75,7 @@ def activate session, on_fork: false DEBUGGER__.warn "ReaderThreadError: #{e}" pp e.backtrace ensure - DEBUGGER__.warn "Disconnected." - @sock = nil - @q_msg.close - @q_msg = nil - @q_ans.close - @q_ans = nil - FileUtils.rm_rf @user_data_dir if @user_data_dir + cleanup_reader end # accept rescue Terminate @@ -215,6 +209,15 @@ def setup_interrupt trap(:SIGURG, prev_handler) end + def cleanup_reader + DEBUGGER__.warn "Disconnected." + @sock = nil + @q_msg.close + @q_msg = nil + @q_ans.close + @q_ans = nil + end + attr_reader :reader_thread class NoRemoteError < Exception; end diff --git a/lib/debug/server_cdp.rb b/lib/debug/server_cdp.rb index 2976d82db..117d6f103 100644 --- a/lib/debug/server_cdp.rb +++ b/lib/debug/server_cdp.rb @@ -452,6 +452,10 @@ def deactivate_bp @q_ans << 'y' end + def cleanup_reader + FileUtils.rm_rf @user_data_dir if @user_data_dir + end + ## Called by the SESSION thread def readline prompt