From 5557fdc47a10a6635fc39f5796675e21da477428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=87=8E=20=E7=9B=B4=E4=BA=BA?= Date: Tue, 26 Oct 2021 21:18:46 +0900 Subject: [PATCH] Define the cleanup method to hide the process for only cdp --- lib/debug/server.rb | 17 ++++++++++------- lib/debug/server_cdp.rb | 4 ++++ 2 files changed, 14 insertions(+), 7 deletions(-) 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