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

Cannot be used in a trap #9

Closed
jrmhaig opened this issue Sep 7, 2016 · 1 comment
Closed

Cannot be used in a trap #9

jrmhaig opened this issue Sep 7, 2016 · 1 comment

Comments

@jrmhaig
Copy link

jrmhaig commented Sep 7, 2016

This gem cannot be used in Signal trap. For example run this:

require 'unicode/display_width'

Signal.trap('USR1') do
  puts Unicode::DisplayWidth.of("⚀")
end

puts Process.pid
sleep(60)

and then execute:

kill -USR1 <process id>

This crashes with the error:

unicode-display_width/lib/unicode/display_width.rb:6:in `require_relative': can't be called from trap context (ThreadError)

I would suggest moving the require_relative to the top so that the file is loaded at the start rather than dynamically.

@janlelis
Copy link
Owner

janlelis commented Sep 7, 2016

Thank you for the bug report. The dynamic loading of the index dates back to when the index size was rather big, which is not the case anymore. So I followed your suggestion and released 1.1.1, which loads the index at start-up time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants