mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
(Merge 3.1) Issue #11768: The signal handler of the signal module only calls
Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or parallel calls. PyErr_SetInterrupt() writes also into the wake up file.
This commit is contained in:
commit
27026f87d8
2 changed files with 20 additions and 10 deletions
|
@ -60,6 +60,10 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #11768: The signal handler of the signal module only calls
|
||||||
|
Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or
|
||||||
|
parallel calls. PyErr_SetInterrupt() writes also into the wake up file.
|
||||||
|
|
||||||
- Issue #11492: fix several issues with header folding in the email package.
|
- Issue #11492: fix several issues with header folding in the email package.
|
||||||
|
|
||||||
- Issue #11852: Add missing imports and update tests.
|
- Issue #11852: Add missing imports and update tests.
|
||||||
|
|
|
@ -165,6 +165,20 @@ checksignals_witharg(void * unused)
|
||||||
return PyErr_CheckSignals();
|
return PyErr_CheckSignals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
trip_signal(int sig_num)
|
||||||
|
{
|
||||||
|
Handlers[sig_num].tripped = 1;
|
||||||
|
if (is_tripped)
|
||||||
|
return;
|
||||||
|
/* Set is_tripped after setting .tripped, as it gets
|
||||||
|
cleared in PyErr_CheckSignals() before .tripped. */
|
||||||
|
is_tripped = 1;
|
||||||
|
Py_AddPendingCall(checksignals_witharg, NULL);
|
||||||
|
if (wakeup_fd != -1)
|
||||||
|
write(wakeup_fd, "\0", 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
signal_handler(int sig_num)
|
signal_handler(int sig_num)
|
||||||
{
|
{
|
||||||
|
@ -182,13 +196,7 @@ signal_handler(int sig_num)
|
||||||
if (getpid() == main_pid)
|
if (getpid() == main_pid)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Handlers[sig_num].tripped = 1;
|
trip_signal(sig_num);
|
||||||
/* Set is_tripped after setting .tripped, as it gets
|
|
||||||
cleared in PyErr_CheckSignals() before .tripped. */
|
|
||||||
is_tripped = 1;
|
|
||||||
Py_AddPendingCall(checksignals_witharg, NULL);
|
|
||||||
if (wakeup_fd != -1)
|
|
||||||
write(wakeup_fd, "\0", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_SIGACTION
|
#ifndef HAVE_SIGACTION
|
||||||
|
@ -946,9 +954,7 @@ PyErr_CheckSignals(void)
|
||||||
void
|
void
|
||||||
PyErr_SetInterrupt(void)
|
PyErr_SetInterrupt(void)
|
||||||
{
|
{
|
||||||
is_tripped = 1;
|
trip_signal(SIGINT);
|
||||||
Handlers[SIGINT].tripped = 1;
|
|
||||||
Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue