Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve signal handling so that it exits gracefully #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/rinruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,12 @@ def eval(string, echo_override=nil)
else
raise ParseError, "Parse error on eval:#{string}"
end
Signal.trap('INT') do
old_handler = Signal.trap('INT') do
puts "#{__FILE__}:#{__LINE__} GOT INT"
@writer.print ''
@reader.gets if @platform !~ /java/
Signal.trap('INT') do
puts "#{__FILE__}:#{__LINE__} GOT INT"
end
return true
end
Expand Down Expand Up @@ -283,8 +285,7 @@ def eval(string, echo_override=nil)
$stdout.flush if @platform !~ /windows/
end
end
Signal.trap('INT') do
end
Signal.trap('INT', old_handler)
true
end

Expand Down