Bug #2761

weird behaviour of readline on OSX 10.6

Added by naruse (Yui NARUSE) over 10 years ago. Updated about 9 years ago.

Target version:
ruby -v:



You seems to use Ruby 1.8.x.
So can you try following?

Index: ext/readline/readline.c
--- ext/readline/readline.c (revision 26664)
+++ ext/readline/readline.c (working copy)
@@ -833,6 +833,12 @@
rl_event_hook = readline_event;

  • rl_catch_signals = 0; +#endif +#ifdef HAVE_RL_CATCH_SIGWINCH
  • rl_catch_sigwinch = 0; +#endif #ifdef HAVE_RL_CLEAR_SIGNALS rl_clear_signals(); #endif Index: ext/readline/extconf.rb =================================================================== --- ext/readline/extconf.rb (revision 26664) +++ ext/readline/extconf.rb (working copy) @@ -59,6 +59,9 @@ have_readline_var("rl_attempted_completion_over") have_readline_var("rl_library_version") have_readline_var("rl_event_hook") +# workaround for native windows. +/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_catch_sigwinch") +/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_catch_signals") have_readline_func("rl_cleanup_after_signal") have_readline_func("rl_clear_signals") have_readline_func("rl_vi_editing_mode")

(2010/02/19 4:59), Andrew Eberbach wrote:


I've been noticing that irb (and as a result script/console in rails)
don't behave correctly with Control C. Nothing would happen when I hit
control C until I hit enter or a few more keys and then it would clear
the line and show a C and reset to the prompt. This doesn't happen on
Linux and it didn't happen on 10.5

If there's a long running process in irb hitting control c works as
expected but not if it's just sitting at a prompt.

I played around with the ext/readline.c and found that if I put a

rl_catch_signals = 0;


in Init_readline()

Then everything works as normal. Should this be added as a patch?
Reading the readline docs it seems to me that what's happening is the
internal readline handler gets stuck sending SIGINT back to the ruby
process even though there's a trap("SIGINT") defined. Any ideas?




Updated by naruse (Yui NARUSE) over 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r26712.
Yui, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.



Updated by hallelujah (Hery Ramihajamalala) over 9 years ago

Just to tell you that this weird behaviour is back because :
The extconf.rb part of this patch was not included in 1.8.7-p334

Maybe an issue with merge ?

Also available in: Atom PDF