-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Control-C doesn't do anything anymore when entering code in IRB #3721
Comments
@mohamedhafez Hmm, that's odd. I see the same result...the Control-C seems to be ignored. |
It doesn't seem like the trap is being installed correctly anymore. |
@mohamedhafez Can you provide info on your environment? OS/platform, JRuby version, etc. |
I'm using jruby 9.0.4.0, and experiencing the issue on both Ubuntu 12.04 and OS X 10.11. Oh and I'm still using Java 7 on both. |
Strange...it appears to be doing a read inside our readline implementation (based on jline) and it does not wake up when the signal triggers an interrupt exception (RubyLex::TerminateLineInput). I'm going to try rb-readline and see if the behavior is better. |
For whatever reason I can't even get signals to register properly when I use rb-readline, so I'm abandoning that path for the moment. Now I'm confused how this ever worked right. We have used jline as our readline impl for many years, and the logic for accepting input has not changed much during that time. The main thread is stuck in a blocking read operation underneath jline, which can't normally be interrupted. The signal is handled by printing out |
Hmm, I tried versions of JRuby 1.7 and 1.6 and they also show the same behavior, so it doesn't seem like this was working any time recently. Do you know of a version where it works? |
So in jruby-1.7.21, doing a control-C will print ^C and a newline in the screen, but won't give you a new prompt the way C-Ruby does. HOWEVER: if you press enter after that point, the code you had entered won't be evaluated, and you'll get the new prompt. This is the way I remember it always being until Jruby 9000 |
Ok, I think this stopped working in part because we started using native channels for stdio. Here's 9.1.3.0 exhibiting the bad behavior:
Now here's 9.1.3.0 with native integration disabled, and it works like it used to:
This could mean that because we're routing around readline, we're interfering with buffering that happens in the regular stdio streams from the JDK. |
I have a fix for jruby-readline that makes it use the same streams as JRuby itself. It appears to restore us basically to 1.7 behavior (there's a CR after the ^C below, as in 1.7):
I'll do some testing with this, but it seems good so far. |
I have pushed the jruby-readline fix to that repo and to JRuby. Please test master and make sure it works for all your IRB console needs. Reopening until we fully release jruby-readline 1.1. |
@mkristian I could not figure out the right way to release jruby-readline-1.1. I tried the release plugin ( |
OH, I found the readme :-) Trying it now. |
I could not get the release to go. It uploaded to Sonatype, but then failed to close/release due to source, javadoc, and pom checks failing. @mkristian You're my only hope! |
@headius I have a look - too bad that it did not just work |
So it turns out the ^C issue might be a jline problem. jline registers its own signal handler so it can intercept various readliney signals. Seems very likely that's getting in our way. |
I may have stumbled on to a way to make things work correctly with rb-readline.
It seems that the signal handling rb-readline does to protect its In any case, with rb-readline patched and our own jline-based readline removed, ^C works exactly like MRI!
I'm also going to explore what it would take to have a pure-FFI readline binding. |
I had almost forgotten about @koichiro's excellent work on readline-ffi so many years ago! readline-ffi is almost perfect. Just gem install it, remove readline from stdlib, and you can do this:
The input is cancelled, but we now see two ^C and we still need to hit enter to get back to a prompt. |
We need to re-spin jruby-readline without this fix and get it into 9.1.6.0 as a default gem. |
@enebo Ok, I guess I answered my own question here. We need to spin jruby-readline for 9.1.6.0. |
The reverted bad fix will go into 9.1.6.0, but any further improvements for this issue will not happen until 9.1.7.0 or later. |
Moving readline rework to 9.3. |
Confirmed this still affects JRuby 9.3.4.0. Linux x64, Java 11 |
This works correctly now with new IRB and reline.
|
In C-Ruby (and also in JRuby until recently), if you pressed Control-C in IRB while in the middle of writing a line of code, any code entered up until then wouldn't be evaluated, and you would be given a new line on which to enter code from scratch. Now, if you press Control-C in the middle of writing a line of code, its as if nothing happened. If you press Control-C and then enter, the code entered up until that point gets evaluated.
The text was updated successfully, but these errors were encountered: