Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a565ab0

Browse files
GH-93312: Add os.PIDFD_NONBLOCK flag (#93313)
1 parent f545fc9 commit a565ab0

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

Doc/library/os.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3897,16 +3897,25 @@ written in Python, such as a mail server's external command delivery program.
38973897

38983898
.. function:: pidfd_open(pid, flags=0)
38993899

3900-
Return a file descriptor referring to the process *pid*. This descriptor can
3901-
be used to perform process management without races and signals. The *flags*
3902-
argument is provided for future extensions; no flag values are currently
3903-
defined.
3900+
Return a file descriptor referring to the process *pid* with *flags* set.
3901+
This descriptor can be used to perform process management without races
3902+
and signals.
39043903

39053904
See the :manpage:`pidfd_open(2)` man page for more details.
39063905

39073906
.. availability:: Linux 5.3+
39083907
.. versionadded:: 3.9
39093908

3909+
.. data:: PIDFD_NONBLOCK
3910+
3911+
This flag indicates that the file descriptor will be non-blocking.
3912+
If the process referred to by the file descriptor has not yet terminated,
3913+
then an attempt to wait on the file descriptor using :manpage:`waitid(2)`
3914+
will immediately return the error :data:`~errno.EAGAIN` rather than blocking.
3915+
3916+
.. availability:: Linux 5.10+
3917+
.. versionadded:: 3.12
3918+
39103919

39113920
.. function:: plock(op)
39123921

Doc/whatsnew/3.12.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ New Modules
9090
Improved Modules
9191
================
9292

93+
os
94+
--
95+
96+
* Add :data:`os.PIDFD_NONBLOCK` to open a file descriptor
97+
for a process with :func:`os.pidfd_open` in non-blocking mode.
98+
(Contributed by Kumar Aditya in :gh:`93312`.)
99+
93100

94101
Optimizations
95102
=============
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add :data:`os.PIDFD_NONBLOCK` flag to open a file descriptor
2+
for a process with :func:`os.pidfd_open` in non-blocking mode.
3+
Patch by Kumar Aditya.

Modules/posixmodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15255,6 +15255,9 @@ all_ins(PyObject *m)
1525515255
#ifdef P_PIDFD
1525615256
if (PyModule_AddIntMacro(m, P_PIDFD)) return -1;
1525715257
#endif
15258+
#ifdef PIDFD_NONBLOCK
15259+
if (PyModule_AddIntMacro(m, PIDFD_NONBLOCK)) return -1;
15260+
#endif
1525815261
#endif
1525915262
#ifdef WEXITED
1526015263
if (PyModule_AddIntMacro(m, WEXITED)) return -1;

0 commit comments

Comments
 (0)