diff --git a/lib/rex/ui/text/irb_shell.rb b/lib/rex/ui/text/irb_shell.rb index 956523cb8c79..49536041dcc5 100644 --- a/lib/rex/ui/text/irb_shell.rb +++ b/lib/rex/ui/text/irb_shell.rb @@ -40,20 +40,18 @@ def run IRB.conf[:MAIN_CONTEXT] = irb.context # Trap interrupt - old_sigint = trap("SIGINT") do - begin + begin + old_sigint = trap("SIGINT") do irb.signal_handle - rescue RubyLex::TerminateLineInput - irb.eval_input end - end - # Keep processing input until the cows come home... - catch(:IRB_EXIT) do - irb.eval_input + # Keep processing input until the cows come home... + catch(:IRB_EXIT) do + irb.eval_input + end + ensure + trap("SIGINT", old_sigint) if old_sigint end - - trap("SIGINT", old_sigint) end end