.. function:: pidfd_open(pid, flags=0)
- Return a file descriptor referring to the process *pid*. This descriptor can
- be used to perform process management without races and signals. The *flags*
- argument is provided for future extensions; no flag values are currently
- defined.
+ Return a file descriptor referring to the process *pid* with *flags* set.
+ This descriptor can be used to perform process management without races
+ and signals.
See the :manpage:`pidfd_open(2)` man page for more details.
.. availability:: Linux 5.3+
.. versionadded:: 3.9
+ .. data:: PIDFD_NONBLOCK
+
+ This flag indicates that the file descriptor will be non-blocking.
+ If the process referred to by the file descriptor has not yet terminated,
+ then an attempt to wait on the file descriptor using :manpage:`waitid(2)`
+ will immediately return the error :data:`~errno.EAGAIN` rather than blocking.
+
+ .. availability:: Linux 5.10+
+ .. versionadded:: 3.12
+
.. function:: plock(op)
Improved Modules
================
+os
+--
+
+* Add :data:`os.PIDFD_NONBLOCK` to open a file descriptor
+ for a process with :func:`os.pidfd_open` in non-blocking mode.
+ (Contributed by Kumar Aditya in :gh:`93312`.)
+
Optimizations
=============
#ifdef P_PIDFD
if (PyModule_AddIntMacro(m, P_PIDFD)) return -1;
#endif
+#ifdef PIDFD_NONBLOCK
+ if (PyModule_AddIntMacro(m, PIDFD_NONBLOCK)) return -1;
+#endif
#endif
#ifdef WEXITED
if (PyModule_AddIntMacro(m, WEXITED)) return -1;