bpo-1054041: Exit properly after an uncaught ^C. by gpshead · Pull Request #11862 · python/cpython

@gpshead

An uncaught KeyboardInterrupt exception means the user pressed ^C and
our code did not handle it.  Programs that install SIGINT handlers are
supposed to reraise the SIGINT signal to the SIG_DFL handler in order
to exit in a manner that their calling process can detect that they
died due to a Ctrl-C.  https://www.cons.org/cracauer/sigint.html

After this change on POSIX systems

 while true; do python -c 'import time; time.sleep(23)'; done

can be stopped via a simple Ctrl-C instead of the shell infinitely
restarting a new python process.

What to do on Windows, or if anything needs to be done there has not
yet been determined.  That belongs in its own PR.

TODO(gpshead): A unittest for this behavior is still needed.

jdemeyer

@gpshead

@gpshead

@gpshead

@blurb-it

@gpshead gpshead changed the title bpo-1054041: Exit properly by a signal after a ^C. bpo-1054041: Exit properly after an uncaught ^C.

Feb 16, 2019

@gpshead

@gpshead

...and rename the windows test to reflect what it does.

@gpshead

@gpshead

@gpshead

eryksun

eryksun

@gpshead gpshead deleted the sigint_issue1054041 branch

February 16, 2019 20:59