closes bpo-38713: Expose P_PIDFD in os if it's defined. (GH-17071)



https://bugs.python.org/issue38713
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 9c907a7..48bd6b9 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -3921,7 +3921,8 @@
 .. function:: waitid(idtype, id, options)
 
    Wait for the completion of one or more child processes.
-   *idtype* can be :data:`P_PID`, :data:`P_PGID` or :data:`P_ALL`.
+   *idtype* can be :data:`P_PID`, :data:`P_PGID`, :data:`P_ALL`, or
+   :data:`P_PIDFD` on Linux.
    *id* specifies the pid to wait on.
    *options* is constructed from the ORing of one or more of :data:`WEXITED`,
    :data:`WSTOPPED` or :data:`WCONTINUED` and additionally may be ORed with
@@ -3946,6 +3947,15 @@
 
    .. versionadded:: 3.3
 
+.. data:: P_PIDFD
+
+   This is a Linux-specific *idtype* that indicates that *id* is a file
+   descriptor that refers to a process.
+
+   .. availability:: Linux 5.4+
+
+   .. versionadded:: 3.9
+
 .. data:: WEXITED
           WSTOPPED
           WNOWAIT
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index 7e77805..1cd21c6 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -150,8 +150,9 @@
 Added :data:`~os.CLD_KILLED` and :data:`~os.CLD_STOPPED` for :attr:`si_code`.
 (Contributed by Dong-hee Na in :issue:`38493`.)
 
-Exposed the Linux-specific :func:`os.pidfd_open` for process management with
-file descriptors. (:issue:`38692`)
+Exposed the Linux-specific :func:`os.pidfd_open` (:issue:`38692`) and
+:data:`os.P_PIDFD` (:issue:`38713`) for process management with file
+descriptors.
 
 threading
 ---------