summaryrefslogtreecommitdiffstats
path: root/Modules/signalmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-102397: Fix segfault from race condition in signal handling (GH-102399)Miss Islington (bot)2023-03-081-0/+4
| | | | | | (cherry picked from commit 1a84cc007e207f2dd61f86a7fc3d86632fdce72f) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* [3.11] gh-98930: improve the docstring of signal.strsignal (GH-99290) (#99449)Gregory P. Smith2022-11-131-3/+4
| | | | | | | | | | Improves the docstring on signal.strsignal to make it explain when it returns a message, None, or when it raises ValueError. Closes GH-98930 Co-authored-by: Gregory P. Smith <greg@krypto.org>. (cherry picked from commit 88385b856490a5ce3c99160bde6050638f81f72e) Co-authored-by: ram vikram singh <ramvikrams243@gmail.com>
* GH-96754: Check whether the interpreter frame is complete before creating ↵Miss Islington (bot)2022-09-131-0/+3
| | | | | | | | | frame object. (GH-96776) (#96787) (cherry picked from commit 12c5f328d2479ac3432df5e266adc4e59adeabfe) Co-authored-by: Mark Shannon <mark@hotpy.org> Co-authored-by: Mark Shannon <mark@hotpy.org>
* gh-84461: Silence some compiler warnings on WASM (GH-93978)Miss Islington (bot)2022-06-201-2/+5
| | | | | (cherry picked from commit 774ef28814d0d9d57ec813cb31b0a7af6c476127) Co-authored-by: Christian Heimes <christian@python.org>
* gh-91320: Use _PyCFunction_CAST() (#92251)Victor Stinner2022-05-031-1/+1
| | | | | | | | | | Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). Change generated by the command: sed -i -e \ 's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \ $(find -name "*.c")
* gh-64783: Fix signal.NSIG value on FreeBSD (#91929)Victor Stinner2022-04-251-16/+18
| | | | | | | | | Fix signal.NSIG value on FreeBSD to accept signal numbers greater than 32, like signal.SIGRTMIN and signal.SIGRTMAX. * Add Py_NSIG constant. * Add pycore_signal.h internal header file. * _Py_Sigset_Converter() now includes the range of valid signals in the error message.
* gh-90623: signal.raise_signal() calls PyErr_CheckSignals() (#91756)Victor Stinner2022-04-211-0/+7
| | | | signal.raise_signal() and os.kill() now call PyErr_CheckSignals() to check immediately for pending signals.
* bpo-47176: Interrupt handling for wasm32-emscripten builds without pthreads ↵Hood Chatham2022-04-031-0/+2
| | | | | | (GH-32209) Co-authored-by: Christian Heimes <christian@python.org> Co-authored-by: Brett Cannon <brett@python.org>
* bpo-23325: Fix SIG_IGN and SIG_DFL int comparison in signal module (GH-31759)Christian Heimes2022-03-081-13/+23
|
* bpo-46836: Rename InterpreterFrame to _PyInterpreterFrame (GH-31583)Victor Stinner2022-02-251-2/+2
| | | | | Rename also struct _interpreter_frame to struct _PyInterpreterFrame. Reduce risk of name conflicts if a project includes pycore_frame.h.
* bpo-46417: signal: move siginfo_type to the module state (GH-30964)Victor Stinner2022-01-271-19/+20
|
* bpo-46417: signal uses PyStructSequence_NewType() (GH-30735)Victor Stinner2022-01-211-7/+9
| | | | | | The signal module now creates its struct_siginfo type as a heap type using PyStructSequence_NewType(), rather than using a static type. Add 'siginfo_type' member to the global signal_state_t structure.
* bpo-45953: Statically allocate the main interpreter (and initial thread ↵Eric Snow2022-01-121-1/+1
| | | | | | | | | state). (gh-29883) Previously, the main interpreter was allocated on the heap during runtime initialization. Here we instead embed it into _PyRuntimeState, which means it is statically allocated as part of the _PyRuntime global. The same goes for the initial thread state (of each interpreter, including the main one). Consequently there are fewer allocations during runtime/interpreter init, fewer possible failures, and better memory locality. FYI, this also helps efforts to consolidate globals, which in turns helps work on subinterpreter isolation. https://bugs.python.org/issue45953
* bpo-45643: Add signal.SIGSTKFLT on platforms where this is defined (GH-29266)Gareth Rees2021-12-131-0/+3
|
* bpo-45855: Replaced deprecated `PyImport_ImportModuleNoBlock` with ↵Kumar Aditya2021-12-121-1/+1
| | | | PyImport_ImportModule (GH-30046)
* bpo-41498: Fix build on platforms without sigset_t (GH-29770)Christian Heimes2021-11-251-3/+10
|
* bpo-45637: Store the frame pointer in the cframe (GH-29267)Mark Shannon2021-10-281-1/+1
| | | * Rename 'frame' to 'current_frame'
* bpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922)Victor Stinner2021-10-131-0/+1
|
* bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)Victor Stinner2021-10-121-1/+1
| | | | | | | * Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
* Fix typos in the Modules directory (GH-28761)Christian Clauss2021-10-071-1/+1
|
* bpo-41710: Add private _PyDeadline_Get() function (GH-28674)Victor Stinner2021-10-011-10/+10
| | | | | | | | Add a private C API for deadlines: add _PyDeadline_Init() and _PyDeadline_Get() functions. * Add _PyTime_Add() and _PyTime_Mul() functions which compute t1+t2 and t1*t2 and clamp the result on overflow. * _PyTime_MulDiv() now uses _PyTime_Add() and _PyTime_Mul().
* bpo-45163: Haiku build fix. (GH-28269)David CARLIER2021-09-111-1/+1
| | | | | | linkage issues mainly for shared libs and missing system library, also little nit into the signal extension as strsignal returns a constant in this platform.
* bpo-44590: Lazily allocate frame objects (GH-27077)Mark Shannon2021-07-261-7/+12
| | | | | | | | | | | | | | * Convert "specials" array to InterpreterFrame struct, adding f_lasti, f_state and other non-debug FrameObject fields to it. * Refactor, calls pushing the call to the interpreter upward toward _PyEval_Vector. * Compute f_back when on thread stack, only filling in value when frame object outlives stack invocation. * Move ownership of InterpreterFrame in generator from frame object to generator object. * Do not create frame objects for Python calls. * Do not create frame objects for generators.
* bpo-43963: Add _signal module state (GH-25676)Victor Stinner2021-04-281-84/+153
| | | | | | | | | | | | | * Add signal_state_t structure and signal_global_state variable. * Add a module state to the _signal module. * Move and rename variables: * DefaultHandler becomes state->default_handler * IgnoreHandler becomes state->ignore_handler * sigint_event becomes state->sigint_event * ItimerError becomes modstate->itimer_error * Rename SetHandler() to set_handler() to be consistent with get_handler().
* bpo-43963: Fix import _signal in subinterpreters (GH-25674)Victor Stinner2021-04-271-27/+41
| | | | | | | Importing the _signal module in a subinterpreter has no longer side effects. signal_module_exec() no longer modifies Handlers and no longer attempts to set SIGINT signal handler in subinterpreters.
* bpo-43356: Allow passing a signal number to interrupt_main() (GH-24755)Antoine Pitrou2021-03-111-30/+45
| | | | Also introduce a new C API ``PyErr_SetInterruptEx(int signum)``.
* bpo-43406: Fix possible race condition where ``PyErr_CheckSignals`` tries to ↵Antoine Pitrou2021-03-051-1/+25
| | | | | | execute a non-Python signal handler (GH-24756) We can receive signals (at the C level, in `trip_signal()` in signalmodule.c) while `signal.signal` is being called to modify the corresponding handler. Later when `PyErr_CheckSignals()` is called to handle the given signal, the handler may be a non-callable object and would raise a cryptic asynchronous exception.
* bpo-31904: Support signal module on VxWorks (GH-23391)pxinwr2020-11-301-0/+4
|
* bpo-41713: Port _signal module to multi-phase init (GH-23355)Victor Stinner2020-11-171-16/+17
| | | | | | Port the _signal extension module to the multi-phase initialization API (PEP 489). Co-Authored-By: Mohamed Koubaa <koubaa.m@gmail.com>
* bpo-41686: Move _Py_RestoreSignals() to signalmodule.c (GH-23353)Victor Stinner2020-11-171-0/+23
|
* bpo-41686: Refactor signal_exec() (GH-23346)Victor Stinner2020-11-171-158/+125
| | | | | | * Add signal_add_constants() function and add ADD_INT_MACRO macro. * The Python SIGINT handler is now installed at the end of signal_exec(). * Use Py_NewRef().
* bpo-41686: Always create the SIGINT event on Windows (GH-23344)Victor Stinner2020-11-171-53/+87
| | | | | | | | | | | | | | bpo-41686, bpo-41713: On Windows, the SIGINT event, _PyOS_SigintEvent(), is now created even if Python is configured to not install signal handlers (PyConfig.install_signal_handlers=0 or Py_InitializeEx(0)). Changes: * Move global variables initialization from signal_exec() to _PySignal_Init() to clarify that they are global variables cleared by _PySignal_Fini(). * _PySignal_Fini() now closes sigint_event. * IntHandler is no longer a global variable.
* bpo-41713: Remove PyOS_InitInterrupts() function (GH-23342)Victor Stinner2020-11-171-12/+25
| | | | | | | Remove the undocumented PyOS_InitInterrupts() C function. * Rename PyOS_InitInterrupts() to _PySignal_Init(). It now installs other signal handlers, not only SIGINT. * Rename PyOS_FiniInterrupts() to _PySignal_Fini()
* bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka2020-10-261-2/+1
| | | | | | | | | | | _PyDict_GetItemId. (GH-22648) These functions are considered not safe because they suppress all internal errors and can return wrong result. PyDict_GetItemString and _PyDict_GetItemId can also silence current exception in rare cases. Remove no longer used _PyDict_GetItemId. Add _PyDict_ContainsId and rename _PyDict_Contains into _PyDict_Contains_KnownHash.
* bpo-41713: _signal doesn't use multi-phase init (GH-22087)Victor Stinner2020-09-041-7/+13
| | | | | Partially revert commit 71d1bd9569c8a497e279f2fea6fe47cd70a87ea3: don't use multi-phase initialization (PEP 489) for the _signal extension module.
* bpo-1635741: Port _signal module to multi-phase init (PEP 489) (GH-22049)Mohamed Koubaa2020-09-031-82/+86
|
* bpo-41675: Modernize siginterrupt calls (GH-22028)Pablo Galindo2020-09-021-1/+13
| | | | | | siginterrupt is deprecated: ./Modules/signalmodule.c:667:5: warning: ‘siginterrupt’ is deprecated: Use sigaction with SA_RESTART instead [-Wdeprecated-declarations] 667 | if (siginterrupt(signalnum, flag)<0) {
* bpo-41146: Convert signal.default_int_handler() to Argument Clinic (GH-21197)Serhiy Storchaka2020-07-121-8/+15
|
* bpo-40826: Add _PyOS_InterruptOccurred(tstate) function (GH-20599)Victor Stinner2020-06-031-2/+12
| | | | | | | | | | | | my_fgets() now calls _PyOS_InterruptOccurred(tstate) to check for pending signals, rather calling PyOS_InterruptOccurred(). my_fgets() is called with the GIL released, whereas PyOS_InterruptOccurred() must be called with the GIL held. test_repl: use text=True and avoid SuppressCrashReport in test_multiline_string_parsing(). Fix my_fgets() on Windows: fgets(fp) does crash if fileno(fp) is closed.
* PyOS_AfterFork_Child() uses PyStatus (GH-20596)Victor Stinner2020-06-021-3/+8
| | | | | | | | PyOS_AfterFork_Child() helper functions now return a PyStatus: PyOS_AfterFork_Child() is now responsible to handle errors. * Move _PySignal_AfterFork() to the internal C API * Add #ifdef HAVE_FORK on _PyGILState_Reinit(), _PySignal_AfterFork() and _PyInterpreterState_DeleteExceptMain().
* bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578)Victor Stinner2020-06-011-2/+3
| | | | PyOS_InterruptOccurred() now fails with a fatal error if it is called with the GIL released.
* bpo-40268: Remove explicit pythread.h includes (#19529)Victor Stinner2020-04-151-2/+0
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-1/+1
|
* bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)Victor Stinner2020-04-141-2/+2
| | | | | | | Rename _PyInterpreterState_GET_UNSAFE() to _PyInterpreterState_GET() for consistency with _PyThreadState_GET() and to have a shorter name (help to fit into 80 columns). Add also "assert(tstate != NULL);" to the function.
* bpo-40082: trip_signal() uses the main interpreter (GH-19441)Victor Stinner2020-04-081-15/+12
| | | | | | | | | | | | | | | | | | | | | | Fix the signal handler: it now always uses the main interpreter, rather than trying to get the current Python thread state. The following function now accepts an interpreter, instead of a Python thread state: * _PyEval_SignalReceived() * _Py_ThreadCanHandleSignals() * _PyEval_AddPendingCall() * COMPUTE_EVAL_BREAKER() * SET_GIL_DROP_REQUEST(), RESET_GIL_DROP_REQUEST() * SIGNAL_PENDING_CALLS(), UNSIGNAL_PENDING_CALLS() * SIGNAL_PENDING_SIGNALS(), UNSIGNAL_PENDING_SIGNALS() * SIGNAL_ASYNC_EXC(), UNSIGNAL_ASYNC_EXC() Py_AddPendingCall() now uses the main interpreter if it fails to the current Python thread state. Convert _PyThreadState_GET() and PyInterpreterState_GET_UNSAFE() macros to static inline functions.
* bpo-38644: Pass tstate explicitly in signalmodule.c (GH-19184)Victor Stinner2020-03-261-63/+89
| | | | PyOS_InterruptOccurred() now checks _Py_ThreadCanHandleSignals() before checking if SIGINT is tripped.
* bpo-40010: COMPUTE_EVAL_BREAKER() checks for subinterpreter (GH-19087)Victor Stinner2020-03-201-17/+12
| | | | | | | | | COMPUTE_EVAL_BREAKER() now also checks if the Python thread state belongs to the main interpreter. Don't break the evaluation loop if there are pending signals but the Python thread state it belongs to a subinterpeter. * Add _Py_IsMainThread() function. * Add _Py_ThreadCanHandleSignals() function.
* bpo-39984: Move pending calls to PyInterpreterState (GH-19066)Victor Stinner2020-03-191-2/+2
| | | | | | | | | | | | | | | | | If Py_AddPendingCall() is called in a subinterpreter, the function is now scheduled to be called from the subinterpreter, rather than being called from the main interpreter. Each subinterpreter now has its own list of scheduled calls. * Move pending and eval_breaker fields from _PyRuntimeState.ceval to PyInterpreterState.ceval. * new_interpreter() now calls _PyEval_InitThreads() to create pending calls lock. * Fix Py_AddPendingCall() for subinterpreters. It now calls _PyThreadState_GET() which works in a subinterpreter if the caller holds the GIL, and only falls back on PyGILState_GetThisThreadState() if _PyThreadState_GET() returns NULL.
* bpo-39984: trip_signal() uses PyGILState_GetThisThreadState() (GH-19061)Victor Stinner2020-03-181-5/+9
| | | | | | | | | | | bpo-37127, bpo-39984: * trip_signal() and Py_AddPendingCall() now get the current Python thread state using PyGILState_GetThisThreadState() rather than _PyRuntimeState_GetThreadState() to be able to get it even if the GIL is released. * _PyEval_SignalReceived() now expects tstate rather than ceval. * Remove ceval parameter of _PyEval_AddPendingCall(): ceval is now get from tstate parameter.
* bpo-39184: Add audit events to functions in `fcntl`, `msvcrt`, `os`, ↵Saiyang Gou2020-02-131-0/+4
| | | | `resource`, `shutil`, `signal`, `syslog` (GH-18407)