Skip to content

Commit ef90261

Browse files
pythongh-141004: Document PyOS_InterruptOccurred (pythonGH-141526)
1 parent 5ac0b55 commit ef90261

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Doc/c-api/sys.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ Operating System Utilities
123123
This is a thin wrapper around either :c:func:`!sigaction` or :c:func:`!signal`. Do
124124
not call those functions directly!
125125
126+
127+
.. c:function:: int PyOS_InterruptOccurred(void)
128+
129+
Check if a :c:macro:`!SIGINT` signal has been received.
130+
131+
Returns ``1`` if a :c:macro:`!SIGINT` has occurred and clears the signal flag,
132+
or ``0`` otherwise.
133+
134+
In most cases, you should prefer :c:func:`PyErr_CheckSignals` over this function.
135+
:c:func:`!PyErr_CheckSignals` invokes the appropriate signal handlers
136+
for all pending signals, allowing Python code to handle the signal properly.
137+
This function only detects :c:macro:`!SIGINT` and does not invoke any Python
138+
signal handlers.
139+
140+
This function is async-signal-safe and this function cannot fail.
141+
The caller must hold an :term:`attached thread state`.
142+
143+
126144
.. c:function:: wchar_t* Py_DecodeLocale(const char* arg, size_t *size)
127145
128146
.. warning::

0 commit comments

Comments
 (0)