Bug 14291 - python KeyboardInterrupt not caught
Summary: python KeyboardInterrupt not caught
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 7.5
Assignee: eager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-25 12:10 UTC by eager
Modified: 2012-08-03 19:25 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Patch to test for KeyboardInterrupt (540 bytes, patch)
2012-06-25 12:10 UTC, eager
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description eager 2012-06-25 12:10:09 UTC
Created attachment 6478 [details]
Patch to test for KeyboardInterrupt

GDB does not pass the KeyboardInterrupt exception to Python when the user terminates paged terminal output generated by Python.  This causes Python scripts to terminate when the user interrupts output.  

(gdb) set height 5
(gdb) python
>try:
>    for i in range(400):
>        print i
>except KeyboardInterrupt:
>    print "caught interrupt"
>end
0
1
2
3
---Type <return> to continue, or q <return> to quit---q
Quit


When the output is generated by a GDB command, the exception is caught and passed to Python.

(gdb) python
>try:
>    gdb.execute("help all")
>except KeyboardInterrupt:
>    print "caught interrupt"
>end

Command class: aliases

ni -- Step one instruction
---Type <return> to continue, or q <return> to quit---q
caught interrupt
Comment 1 Tom Tromey 2012-08-03 17:57:36 UTC
FWIW this patch looks reasonable.
Please send it to gdb-patches.
Comment 2 eager 2012-08-03 19:23:18 UTC
Applied some time ago, IIRC.

On 08/03/2012 10:57 AM, tromey at redhat dot com wrote:
> http://sourceware.org/bugzilla/show_bug.cgi?id=14291
>
> Tom Tromey <tromey at redhat dot com> changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |tromey at redhat dot com
>
> --- Comment #1 from Tom Tromey <tromey at redhat dot com> 2012-08-03 17:57:36 UTC ---
> FWIW this patch looks reasonable.
> Please send it to gdb-patches.
>
Comment 3 Tom Tromey 2012-08-03 19:25:33 UTC
(In reply to comment #2)
> Applied some time ago, IIRC.

Indeed it was.
Thanks.