Issue1270

classification
Title: CRTL+C kills Jython console
Type: Severity: normal
Components: None Versions: Jython 2.5
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: a_o_m, amak, boisgera, fwierzbicki, nriley, pekka.klarck, pjenvey, zyasoft
Priority: low Keywords: console

Created on 2009-03-09.21:15:47 by boisgera, last changed 2015-03-11.23:36:19 by zyasoft.

Messages
msg4212 (view) Author: (boisgera) Date: 2009-03-09.21:15:47
CTRL+C in Jython 2.5b2 does not exit the console properly: the shell
behaves strangely afterwards, with NEWLINE not working anymore for example.
msg4213 (view) Author: (boisgera) Date: 2009-03-09.21:54:53
Well, to be fair:

  1. CTRL+D exits properly,

  2. an exit on CTRL+C (clean or not) is not the CPython behavior. 
Instead it displays 'KeyboardInterrupt' and does not exit.
msg4214 (view) Author: Nicholas Riley (nriley) Date: 2009-03-09.22:25:19
This will likely be fixable on Unix by registering a SIGINT handler. Not 
sure about Windows.
msg4435 (view) Author: Jim Baker (zyasoft) Date: 2009-04-04.03:25:59
This may be a function of the underlying readline support. Now that we
have JLine installed by default, on OS X at the very least it exhibits
the same behavior as CPython. No signal handling required!
msg4746 (view) Author: Philip Jenvey (pjenvey) Date: 2009-05-29.01:14:09
boisgera, is this still a problem?
msg4798 (view) Author: (boisgera) Date: 2009-06-05.11:49:47
I removed my registry file so that GnuReadline does not kick in. The
registry file was:

   python.console=org.python.util.ReadlineConsole
   python.console.readlinelib=GnuReadline

That change alone did cause the beta 3 version to exit properly on a
CTRL+C. The RC3 version exhibits the same behavior (and the rev. 6450 as
well): clean exit on CTRL+C when the Readline console is not selected,
ugly exit when the registry file is present, and never the
'KeyboardInterrupt' behavior.
msg4848 (view) Author: Philip Jenvey (pjenvey) Date: 2009-06-22.02:14:35
this is a dupe of #1746106
msg5190 (view) Author: Pekka Klärck (pekka.klarck) Date: 2009-09-24.12:53:56
I just tested this with 2.5 rc 3 and could still reproduce the problem.
Is this a regression?

Ctrl-c killing the console isn't that big problem, but the fact that
ctrl-c cannot be caught as KeyboardInterrupt (issue 1313) means that I
cannot implement graceful shutdown from the CLI to my app easily. I
assume these problems have the same root cause.
msg5191 (view) Author: Pekka Klärck (pekka.klarck) Date: 2009-09-24.12:59:16
Ooops, the version I used in testing was 2.5.1 RC 3 i.e. the latest
available release.
msg5194 (view) Author: Jim Baker (zyasoft) Date: 2009-09-24.15:35:31
This is still outstanding; there has been no regression.
msg5195 (view) Author: Pekka Klärck (pekka.klarck) Date: 2009-09-24.15:39:01
I thought this was closed as the resolution says 'fixed'.
msg7406 (view) Author: Alan Kennedy (amak) Date: 2012-08-14.21:45:35
I think that this is to do with the JLineConsole.

If you change the "python.console" property in the registry file to "org.python.util.InteractiveConsole", i.e

python.console=org.python.util.InteractiveConsole

The ctrl-c starts working fine.

If you leave it at the default JLine console (http://jline.sourceforge.net/) then ctrl-c seems to get treated as a normal character (shows up as a heart symbol on my windows command line).

I suggest you try a different console class until this is fixed.

I'll look into how we can address this.

In the meantime, I would be interested in reports to see if changing the console class fixes the issue on various platforms.
msg7885 (view) Author: Philip Jenvey (pjenvey) Date: 2013-03-01.20:26:53
Isn't this only an issue on Windows? As Jim pointed out, it's ok on OS X at least (I can't reproduce it on there as of today w/ 2.5.x)
msg7890 (view) Author: Alan Kennedy (amak) Date: 2013-03-01.20:50:26
Nobody specified a platform.

I did use windows and experienced an issue, but a different one to what this bug report is about. And still do.

X:\xhaus\jython\jython_27_2016\dist>java -jar jython.jar
Jython 2.7b1+ (default:e80a189574d0+, Feb 28 2013, 22:54:17)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_41
Type "help", "copyright", "credits" or "license" for more information.
>>> ♥♥♥♥♥♥♥♥
  File "<stdin>", line 1
    ♥♥♥♥♥♥♥♥
    ^
SyntaxError: no viable alternative at character '♥'
>>>

With each heart symbol representing a Ctrl-C.

The fact that boisgera and pekka.klarck experience different behaviour (i.e. console killed, no KeyboardInterrupt generated) indicates that they are not using windows, since they did not see heart symbols, as I do.

If it is windows only (requires evidence), then we *could* fix it by specializing the installer to default to a different console on windows.

But I don't like that solution. I'd rather the same console everywhere.

Doesn't jruby use jline as well? They must have had similar problems.
msg7891 (view) Author: Philip Jenvey (pjenvey) Date: 2013-03-01.20:57:31
Well we don't generate a KeyboardInterrupt under any circumstances (which is really a separate issue #1313)
msg7892 (view) Author: Alan Kennedy (amak) Date: 2013-03-01.21:20:30
Indeed, it looks like #1270 and #1313 are the same issue.

On #1313, pekka.klarck declares that he uses OSX.

"""
This problem can be tested with the attached script. When I execute it
with Jython (tested both with 2.2 and 2.5b3) on my OS X and press ctrl-c
it simply quits without even a traceback. With CPython it prints both
'KeyboardInterrupt' and 'Bye!' before exiting cleanly.
"""

#1313 should be closed as a duplicate of #1270, or vice versa.
msg7894 (view) Author: Pekka Klärck (pekka.klarck) Date: 2013-03-01.23:50:31
I also get hearts on Windows 7 and on Linux the console is killed. Tested with 2.5.3 on both. Don't anymore have OSX for testing.
msg9627 (view) Author: Jim Baker (zyasoft) Date: 2015-03-11.23:36:19
Useful content in #1313, which is a duplicate. There is no easy solution for Jython, although partial solutions certainly exist. Perhaps we can document them?
History
Date User Action Args
2015-03-11 23:36:19zyasoftsetassignee: amak ->
messages: + msg9627
2013-03-01 23:50:31pekka.klarcksetmessages: + msg7894
2013-03-01 21:20:30amaksetmessages: + msg7892
2013-03-01 20:57:31pjenveysetmessages: + msg7891
2013-03-01 20:50:27amaksetmessages: + msg7890
2013-03-01 20:26:53pjenveysetmessages: + msg7885
2013-02-25 21:55:46amaksetkeywords: + console
2013-02-25 19:05:47fwierzbickisetversions: + Jython 2.5, - 2.5.1
2012-08-14 21:46:51amaksetstatus: pending -> open
2012-08-14 21:45:35amaksetassignee: amak
resolution: fixed ->
messages: + msg7406
nosy: + amak
2009-09-24 15:39:01pekka.klarcksetmessages: + msg5195
2009-09-24 15:35:31zyasoftsetmessages: + msg5194
2009-09-24 12:59:16pekka.klarcksetmessages: + msg5191
2009-09-24 12:53:57pekka.klarcksetnosy: + pekka.klarck
messages: + msg5190
title: CRTL+C in Jython 2.5b2 Console -> CRTL+C kills Jython console
2009-06-22 02:14:35pjenveysetnosy: + a_o_m
messages: + msg4848
2009-06-05 11:49:48boisgerasetmessages: + msg4798
2009-05-29 01:14:09pjenveysetnosy: + pjenvey
messages: + msg4746
2009-04-04 03:25:59zyasoftsetstatus: open -> pending
resolution: fixed
messages: + msg4435
nosy: + zyasoft
2009-03-14 14:18:13fwierzbickisetnosy: + fwierzbicki
2009-03-14 14:18:02fwierzbickisetpriority: low
versions: + 2.5.1
2009-03-09 22:25:19nrileysetnosy: + nriley
messages: + msg4214
2009-03-09 21:54:53boisgerasetmessages: + msg4213
2009-03-09 21:15:47boisgeracreate