]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141004: Document `PyOS_InterruptOccurred` (GH-141526)
authorStan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Fri, 14 Nov 2025 11:20:36 +0000 (11:20 +0000)
committerGitHub <noreply@github.com>
Fri, 14 Nov 2025 11:20:36 +0000 (06:20 -0500)
Doc/c-api/sys.rst

index 336e3ef96400f4a4edd6e360c4ccda1afb50afa9..ee73c1c8adaa7b3a3c81b9f832c86e8a3e81866e 100644 (file)
@@ -123,6 +123,24 @@ Operating System Utilities
    This is a thin wrapper around either :c:func:`!sigaction` or :c:func:`!signal`.  Do
    not call those functions directly!
 
+
+.. c:function:: int PyOS_InterruptOccurred(void)
+
+   Check if a :c:macro:`!SIGINT` signal has been received.
+
+   Returns ``1`` if a :c:macro:`!SIGINT` has occurred and clears the signal flag,
+   or ``0`` otherwise.
+
+   In most cases, you should prefer :c:func:`PyErr_CheckSignals` over this function.
+   :c:func:`!PyErr_CheckSignals` invokes the appropriate signal handlers
+   for all pending signals, allowing Python code to handle the signal properly.
+   This function only detects :c:macro:`!SIGINT` and does not invoke any Python
+   signal handlers.
+
+   This function is async-signal-safe and this function cannot fail.
+   The caller must hold an :term:`attached thread state`.
+
+
 .. c:function:: wchar_t* Py_DecodeLocale(const char* arg, size_t *size)
 
    .. warning::