summaryrefslogtreecommitdiff
path: root/Modules/signalmodule.c
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2019-05-23 22:30:00 +0200
committerAntoine Pitrou <antoine@python.org>2019-05-23 22:30:00 +0200
commit608876b6b1eb59538e6c29671a733033fb8b5be7 (patch)
tree4d7501f1f43b222329912a33a60518ada47dbf81 /Modules/signalmodule.c
parentb82e17e626f7b1cd98aada0b1ebb65cb9f8fb184 (diff)
downloadcpython-git-608876b6b1eb59538e6c29671a733033fb8b5be7.tar.gz
bpo-23395: Fix PyErr_SetInterrupt if the SIGINT signal is ignored or not handled (GH-7778)
``_thread.interrupt_main()`` now avoids setting the Python error status if the ``SIGINT`` signal is ignored or not handled by Python.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r--Modules/signalmodule.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index b5e6250b1b..221b74fac6 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1683,13 +1683,18 @@ _PyErr_CheckSignals(void)
}
-/* Replacements for intrcheck.c functionality
- * Declared in pyerrors.h
- */
+/* Simulate the effect of a signal.SIGINT signal arriving. The next time
+ PyErr_CheckSignals is called, the Python SIGINT signal handler will be
+ raised.
+
+ Missing signal handler for the SIGINT signal is silently ignored. */
void
PyErr_SetInterrupt(void)
{
- trip_signal(SIGINT);
+ if ((Handlers[SIGINT].func != IgnoreHandler) &&
+ (Handlers[SIGINT].func != DefaultHandler)) {
+ trip_signal(SIGINT);
+ }
}
void