This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: KeyboardInterrupt while waiting for sys.ps2 input kills interpreter (PR#309)
Type: Stage:
Components: Extension Modules Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: twouters Nosy List: gvanrossum, twouters
Priority: normal Keywords:

Created on 2000-07-31 21:09 by anonymous, last changed 2022-04-10 16:02 by admin. This issue is now closed.

Messages (5)
msg212 - (view) Author: Nobody/Anonymous (nobody) Date: 2000-07-31 21:09
Jitterbug-Id: 309
Submitted-By: skip@mojam.com
Date: Fri, 28 Apr 2000 17:00:40 -0400 (EDT)
Version: 1.5.2, 1.6a2
OS: Linux


If you hit Ctrl-C while the Python interpreter is sitting at the ps2 prompt the
interpreter exits instead of returning you to the top-level prompt.

% python
Python 1.5.2+ (#12, Feb 17 2000, 14:52:05)  [GCC pgcc-2.91.66 19990314
(egcs-1.1.2 release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> if 1:
... 

% PYTHONSTARTUP= ./python
Python 1.6a2 (#7, Apr 24 2000, 23:02:54)  [GCC pgcc-2.91.66 19990314 (egcs-1.1.2
release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> if 1:
... 

When run under gdb's control, you can see what's happening:

% gdb ./python
GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-mandrake-linux"...
(gdb) set env PYTHONSTARTUP ""
(gdb) run
Starting program: /home/beluga/skip/src/python/dist/src/./python 
Python 1.6a2 (#7, Apr 24 2000, 23:02:54)  [GCC pgcc-2.91.66 19990314 (egcs-1.1.2
release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> if 1:
... 
Program received signal SIGINT, Interrupt.
0x4013bf14 in __libc_read () from /lib/libc.so.6
(gdb) bt
#0  0x4013bf14 in __libc_read () from /lib/libc.so.6
(gdb) c
Continuing.

  File "<stdin>", line 2
    
    ^
SyntaxError: invalid syntax
>>> 

It appears that SIGINT isn't handled properly when awaiting console input in
certain circumstances.  If you can entice the program to continue, things work
okay.  I don't know interrupt handling from a hole in the ground or I'd
investigate further.  It is quite annoying, especially considering that
Python's input history isn't continuous across sessions...


Skip





====================================================================
Audit trail:
Mon May 22 17:23:42 2000	guido	changed notes
Mon May 22 17:23:42 2000	guido	moved from incoming to open
msg213 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2000-07-31 21:40
This seems to be platform specific: On Linux, up-to-date CVS compile, this is reproducible. On BSDI 4.1, however, with an almost-up-to-date CVS compile, ^C doesn't exit the interpreter.
msg214 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2000-08-06 11:57
Oh, and it's also definately readline-related. (without readline compiled in, the bug doesn't get triggered, in any case.)
msg215 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2000-08-09 15:59
I've been toying with this, and the problem *is* readline. Readline overrides a number of signal handlers, in order to do cleanup when exiting, and apparently does not restore them on exit :-S The signals readline 'overrides' the handlers of are:

SIGINT
SIGALRM
SIGTSTP
SIGTTOU
SIGTTIN
SIGTERM
SIGWINCH

Which means that the signal handlers for these signals *vanish* when using readline. Interactive mode uses readline, but scripts can themselves, too. I'm not sure why this isn't showing on BSDI, but it might have something to do with the BSD vs the SysV signal handling routines. I'm also not sure if it's possible to fix this problem; it might be a bug in readline, or it might be documented behaviour. But I wasn't able to find a reference to signal handling in the 2.2.1 readline info files.
msg216 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2000-09-22 03:33
I'm quite confident that this was fixed by my checkin (last Sunday) to deal with the mixing of signal() and sigaction(), which makes it a duplicate of bug #110611.
I'm closing this for Thomas.
History
Date User Action Args
2022-04-10 16:02:09adminsetgithub: 32712
2000-07-31 21:09:48anonymouscreate