Skip to content

Commit 8da8182

Browse files
committed
Rescue ArgumentError from Signal.trap(:TSTP) on Windows
1 parent ebbd007 commit 8da8182

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/reline/line_editor.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,13 @@ def reset(prompt = '', encoding:)
170170
@old_trap.call
171171
end
172172
}
173-
@old_tstp_trap = Signal.trap(:TSTP) {
174-
Reline::IOGate.ungetc("\C-z".ord)
175-
@old_tstp_trap.call if @old_tstp_trap.respond_to?(:call)
176-
}
173+
begin
174+
@old_tstp_trap = Signal.trap(:TSTP) {
175+
Reline::IOGate.ungetc("\C-z".ord)
176+
@old_tstp_trap.call if @old_tstp_trap.respond_to?(:call)
177+
}
178+
rescue ArgumentError
179+
end
177180
Reline::IOGate.set_winch_handler do
178181
@rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
179182
old_screen_size = @screen_size
@@ -215,7 +218,10 @@ def reset(prompt = '', encoding:)
215218

216219
def finalize
217220
Signal.trap('SIGINT', @old_trap)
218-
Signal.trap('SIGTSTP', @old_tstp_trap)
221+
begin
222+
Signal.trap('SIGTSTP', @old_tstp_trap)
223+
rescue ArgumentError
224+
end
219225
end
220226

221227
def eof?

0 commit comments

Comments
 (0)