Skip to content

Commit

Permalink
Rescue ArgumentError from Signal.trap(:TSTP) on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Sep 6, 2021
1 parent ebbd007 commit 8da8182
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,13 @@ def reset(prompt = '', encoding:)
@old_trap.call
end
}
@old_tstp_trap = Signal.trap(:TSTP) {
Reline::IOGate.ungetc("\C-z".ord)
@old_tstp_trap.call if @old_tstp_trap.respond_to?(:call)
}
begin
@old_tstp_trap = Signal.trap(:TSTP) {
Reline::IOGate.ungetc("\C-z".ord)
@old_tstp_trap.call if @old_tstp_trap.respond_to?(:call)
}
rescue ArgumentError
end
Reline::IOGate.set_winch_handler do
@rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
old_screen_size = @screen_size
Expand Down Expand Up @@ -215,7 +218,10 @@ def reset(prompt = '', encoding:)

def finalize
Signal.trap('SIGINT', @old_trap)
Signal.trap('SIGTSTP', @old_tstp_trap)
begin
Signal.trap('SIGTSTP', @old_tstp_trap)
rescue ArgumentError
end
end

def eof?
Expand Down

0 comments on commit 8da8182

Please sign in to comment.