]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
closes bpo-38713: Expose P_PIDFD in os if it's defined. (GH-17071)
authorBenjamin Peterson <benjamin@python.org>
Wed, 6 Nov 2019 05:58:31 +0000 (21:58 -0800)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 6 Nov 2019 05:58:31 +0000 (21:58 -0800)
https://bugs.python.org/issue38713

Doc/library/os.rst
Doc/whatsnew/3.9.rst
Misc/NEWS.d/next/Library/2019-11-05-21-22-22.bpo-38713.bmhquU.rst [new file with mode: 0644]
Modules/posixmodule.c
configure
configure.ac
pyconfig.h.in

index 9c907a7ee5911bc035f4d974eb97f56c77d8e244..48bd6b95a9b39ef1e68b345345de72ed7ee89352 100644 (file)
@@ -3921,7 +3921,8 @@ written in Python, such as a mail server's external command delivery program.
 .. 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 @@ written in Python, such as a mail server's external command delivery program.
 
    .. 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
index 7e778058c8ded2768187df51106f1e71de09dd7e..1cd21c6ab8f71beb8eb9e7d27c43eaeb80af0ee1 100644 (file)
@@ -150,8 +150,9 @@ os
 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
 ---------
diff --git a/Misc/NEWS.d/next/Library/2019-11-05-21-22-22.bpo-38713.bmhquU.rst b/Misc/NEWS.d/next/Library/2019-11-05-21-22-22.bpo-38713.bmhquU.rst
new file mode 100644 (file)
index 0000000..a227197
--- /dev/null
@@ -0,0 +1,2 @@
+Add :data:`os.P_PIDFD` constant, which may be passed to :func:`os.waitid` to
+wait on a Linux process file descriptor.
index 46cf7b2f55ac18f6a3e2279d228c3cab9904b63e..f7386300c5691ac7f8be7a4625aa31c91b151cf0 100644 (file)
@@ -85,6 +85,9 @@ corresponding Unix manual entries for more information on calls.");
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>           /* For WNOHANG */
 #endif
+#ifdef HAVE_LINUX_WAIT_H
+#include <linux/wait.h> // For P_PIDFD
+#endif
 
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
@@ -14099,6 +14102,9 @@ all_ins(PyObject *m)
     if (PyModule_AddIntMacro(m, P_PID)) return -1;
     if (PyModule_AddIntMacro(m, P_PGID)) return -1;
     if (PyModule_AddIntMacro(m, P_ALL)) return -1;
+#ifdef P_PIDFD
+    if (PyModule_AddIntMacro(m, P_PIDFD)) return -1;
+#endif
 #endif
 #ifdef WEXITED
     if (PyModule_AddIntMacro(m, WEXITED)) return -1;
index 50840ac15210554e2466ab168735c783b8a8fcdc..44f14c3c2cfe1b63579c115fdfb752d42c5af6ad 100755 (executable)
--- a/configure
+++ b/configure
@@ -782,6 +782,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -895,6 +896,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1147,6 +1149,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1284,7 +1295,7 @@ fi
 for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
                datadir sysconfdir sharedstatedir localstatedir includedir \
                oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-               libdir localedir mandir
+               libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1437,6 +1448,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -7917,7 +7929,7 @@ sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
 sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
 libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
 linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \
-sys/endian.h sys/sysmacros.h linux/memfd.h sys/memfd.h sys/mman.h
+sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h sys/mman.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
index 20d8a5239f1731d691fb1c215e957cb37a7d546f..0b28dda44cdb8e5773741e3191f02c144463f558 100644 (file)
@@ -2161,7 +2161,7 @@ sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
 sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
 libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
 linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \
-sys/endian.h sys/sysmacros.h linux/memfd.h sys/memfd.h sys/mman.h)
+sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h sys/mman.h)
 AC_HEADER_DIRENT
 AC_HEADER_MAJOR
 
index 9595d7537de4708d5bc0779ef9cc4a815ca4df8d..50af4c6fee43def07f79bd7be2105b46f26d5b2a 100644 (file)
 /* Define to 1 if you have the <linux/vm_sockets.h> header file. */
 #undef HAVE_LINUX_VM_SOCKETS_H
 
+/* Define to 1 if you have the <linux/wait.h> header file. */
+#undef HAVE_LINUX_WAIT_H
+
 /* Define to 1 if you have the `lockf' function. */
 #undef HAVE_LOCKF