]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
linux: Add pidfd_open
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 28 Jan 2022 18:27:40 +0000 (15:27 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 17 May 2022 13:32:28 +0000 (10:32 -0300)
This was added on Linux 5.3 (32fcb426ec001cb6d5a4a195091a8486ea77e2df)
as a way to retrieve a pid file descriptors for process that has not
been created CLONE_PIDFD (by usual fork/clone).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
39 files changed:
NEWS
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/Versions
sysdeps/unix/sysv/linux/aarch64/libc.abilist
sysdeps/unix/sysv/linux/alpha/libc.abilist
sysdeps/unix/sysv/linux/arc/libc.abilist
sysdeps/unix/sysv/linux/arm/be/libc.abilist
sysdeps/unix/sysv/linux/arm/le/libc.abilist
sysdeps/unix/sysv/linux/csky/libc.abilist
sysdeps/unix/sysv/linux/hppa/libc.abilist
sysdeps/unix/sysv/linux/i386/libc.abilist
sysdeps/unix/sysv/linux/ia64/libc.abilist
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
sysdeps/unix/sysv/linux/nios2/libc.abilist
sysdeps/unix/sysv/linux/or1k/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
sysdeps/unix/sysv/linux/sh/be/libc.abilist
sysdeps/unix/sysv/linux/sh/le/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
sysdeps/unix/sysv/linux/sys/pidfd.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/syscalls.list
sysdeps/unix/sysv/linux/tst-pidfd-consts.py [new file with mode: 0644]
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist

diff --git a/NEWS b/NEWS
index ebde949d58b92c4be70c97b18137dbaf7701e866..966c696bb0991aa3fb98d846cd457f4a24f78311 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,10 @@ Major new features:
   -z pack-relative-relocs option, which is supported for some targets
   in recent binutils versions.  Lazy binding doesn't apply to DT_RELR.
 
+* On Linux, the pidfd_open function has been added.  The pidfd functionality
+  provides access to a process while avoiding the issue of PID reuse on
+  tranditional Unix systems.
+
 Deprecated and removed features, and other changes affecting compatibility:
 
 * Support for prelink will be removed in the next release; this includes
index 89cb005c7d907acf783e8a4f341f49a04d253dc9..11c15eca66f88b6dbb6dbfb42e9f09bfe2f6a2d8 100644 (file)
@@ -113,7 +113,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
                  bits/types/struct_shmid64_ds.h \
                  bits/types/struct_shmid64_ds_helper.h \
                  bits/pthread_stack_min.h bits/pthread_stack_min-dynamic.h \
-                 sys/rseq.h bits/rseq.h
+                 sys/rseq.h bits/rseq.h \
+                 sys/pidfd.h
 
 tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
         tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
@@ -240,6 +241,14 @@ $(objpfx)tst-mman-consts.out: ../sysdeps/unix/sysv/linux/tst-mman-consts.py
          < /dev/null > $@ 2>&1; $(evaluate-test)
 $(objpfx)tst-mman-consts.out: $(sysdeps-linux-python-deps)
 
+tests-special += $(objpfx)tst-pidfd-consts.out
+$(objpfx)tst-pidfd-consts.out: ../sysdeps/unix/sysv/linux/tst-pidfd-consts.py
+       $(sysdeps-linux-python) \
+         ../sysdeps/unix/sysv/linux/tst-pidfd-consts.py \
+           $(sysdeps-linux-python-cc) \
+         < /dev/null > $@ 2>&1; $(evaluate-test)
+$(objpfx)tst-pidfd-consts.out: $(sysdeps-linux-python-deps)
+
 tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0
 
 endif # $(subdir) == misc
index ded087f30ea953fc0312aaa708d76697db2c7354..4516a8f8f4d036cbe9acb8c13eda23c09b8dc836 100644 (file)
@@ -299,6 +299,9 @@ libc {
 %endif
     epoll_pwait2;
   }
+  GLIBC_2.36 {
+    pidfd_open;
+  }
   GLIBC_PRIVATE {
     # functions used in other libraries
     __syscall_rt_sigqueueinfo;
index 1b63d9e447f16862e9941731e07e74327b002d59..771d580bd918956c8a5eefc7cd2f2af8525a4e62 100644 (file)
@@ -2616,3 +2616,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index e7e4cf7d2afe8e378ca882e2c5bb4ce7f61492a5..a9c4e5b1d24f98089985f42ac31421693bbed583 100644 (file)
@@ -2713,6 +2713,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
index bc3d228e3183bbff7a1fa4ce834320e5a5766d26..e147803167fa6d138124227e43be53358ea49036 100644 (file)
@@ -2377,3 +2377,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index db7039c4aba3a2cb7868fb23d3bebce14aa619a0..4d1695e4a48ca1d618ecbe2c65142bcc80165c22 100644 (file)
@@ -496,6 +496,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
index d2add4fb49bec9ae41303e75dc6d11837f557420..600e8a977a0ced401c033dc8271914ee51e0c7eb 100644 (file)
@@ -493,6 +493,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
index 355d72a30c41b668bdd17a89b887d1281e54dd6c..be1671372afff928926b7291a77af50ff5758ef3 100644 (file)
@@ -2652,3 +2652,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index 3df39bb28cc68f8ae5cfbb0595ba8b2d4bb56e64..7d09b909cd4f59c2dd89fa3d63c3b4a66b6eeacd 100644 (file)
@@ -2601,6 +2601,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index c4da358f80c4aae3364996888d064a8827508e33..89da416c3761fca1a61f29638e44242f660578ae 100644 (file)
@@ -2785,6 +2785,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index 241bac70ea8222301d8e95ab03794088ca1c5841..4e4faed24bfb549f392566b8fe6b8d277ce6399c 100644 (file)
@@ -2551,6 +2551,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index 78bf372b729a2aa531fa02cbf5ca221595da2e92..83f61f95fd0062c479ec487465e4f4eefeff3e72 100644 (file)
@@ -497,6 +497,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
 GLIBC_2.4 _IO_2_1_stdin_ D 0x98
index 00df5c901f5a608b74dd7fc3dc00fa2c2e386ee3..9f815f8b9988af26ab65d6e2bb430c313d144bc8 100644 (file)
@@ -2728,6 +2728,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index e8118569c30bbd1ed143fe040b4a07891052f631..d7585940328bb272e0a50b3df7b5694cefc4450c 100644 (file)
@@ -2701,3 +2701,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index c0d2373e64a2670042a0062b310f1ba16b0f1c59..6d9d415936d2de67bd6e4dc947bfecd12682394d 100644 (file)
@@ -2698,3 +2698,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index 2d0fd04f54bf349598574469d0291b3420211e2e..b31f7b88cd55211b2459b0496043e3d8ceec71be 100644 (file)
@@ -2693,6 +2693,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index e39ccfb312c61434c6231885be9e3959d309b72c..98ebcbdcbc8e1fbc0cc90821d345b76dff62d3a6 100644 (file)
@@ -2691,6 +2691,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index 1e900f86e43b49ec54a5281a769c74c6590eaed5..e6bae7d52d5d7edfec0692f8ce82905549801e13 100644 (file)
@@ -2699,6 +2699,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index 9145ba79316952fd951dd698d29e890d419e817f..19f575d22dabd697dca2d13766457125e80a37ea 100644 (file)
@@ -2602,6 +2602,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index e95d60d92622ea38c1b8c8534df8ec56387d7a48..04779199c2fdaf80480d930e97bbc79e791a89e5 100644 (file)
@@ -2740,3 +2740,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index ca934e374b5dd280af2270c22cdc8d58aa800d84..df6ecdec8b6f9942fdee507260fc63aa12e85ee5 100644 (file)
@@ -2123,3 +2123,4 @@ GLIBC_2.35 wprintf F
 GLIBC_2.35 write F
 GLIBC_2.35 writev F
 GLIBC_2.35 wscanf F
+GLIBC_2.36 pidfd_open F
index 3820b9f23524fb40aee2cf56feb89fa357b2109f..b618808e133fa6ab9fcce8770de864849b28a5ff 100644 (file)
@@ -2755,6 +2755,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
index 464dc27fcd688a94d9c678e8c34c4eab0ff7bd5c..19eb5c457685acbb2ed73fda8a8d5487250d0a40 100644 (file)
@@ -2788,6 +2788,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
index 2f7e58747fb9a6b1ded86fcfed436e137a6c69b7..a54d3a16a2982b2cc03111f1e731270e2654b0d9 100644 (file)
@@ -2510,6 +2510,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
index 4f3043d913781166466f7177113836fcc841294b..e829f4fb425a77f726803203692b8b7dbc728901 100644 (file)
@@ -2812,3 +2812,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index 84b6ac815a622edaa039a9153e7c4c69b84a52d7..2f0c9a81d2416f8d9956446c6c6e469821539fb4 100644 (file)
@@ -2379,3 +2379,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index 4d5c19c56a03175d1bffab094ac877979a39d19e..e4b61e880a1a897c5d2dc0205f4c05cec9da3045 100644 (file)
@@ -2579,3 +2579,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
index 7c5ee8d56959fb3596b376906923868bc0014f1c..b7ee961dd616f9bab406f6704cc92fdf483f6921 100644 (file)
@@ -2753,6 +2753,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
index 50de0b46cf078fdaa240a1078b1c2b313e999304..53d49565b3ed565f0052f47b0bfd7664b51a4f03 100644 (file)
@@ -2547,6 +2547,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
index 66fba013caaf0200112ffab0bf7c3d9bde8dfafa..2179df05fa5773638f9ec3909246a45e989d8fbb 100644 (file)
@@ -2608,6 +2608,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index 38703f8aa039b97675303c96b3afc8a499b988b9..bbf00df5ebdb184f27a403569b90ce24d9472581 100644 (file)
@@ -2605,6 +2605,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index 6df55eb76582a3975cc5ea727f15bb80f2f3c486..e452cf8c88af1ef374563865270e4b32fd155e93 100644 (file)
@@ -2748,6 +2748,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
index b90569d8814c603a8b1b9f24f7bd2bab302ef77d..0c401996f8d20020c21acbe40c0d0c63a4cdb8a7 100644 (file)
@@ -2574,6 +2574,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sys/pidfd.h b/sysdeps/unix/sysv/linux/sys/pidfd.h
new file mode 100644 (file)
index 0000000..dab2710
--- /dev/null
@@ -0,0 +1,33 @@
+/* Wrapper for file descriptors that refers to a process functions.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _PIDFD_H
+
+#include <fcntl.h>
+#include <bits/types/siginfo_t.h>
+
+#define PIDFD_NONBLOCK O_NONBLOCK
+
+/* Returns a file descriptor that refers to the process PID.  The
+   close-on-exec is set on the file descriptor.
+
+   The FLAGS argument is reserved for future use, it must be specified
+   as 0.  */
+extern int pidfd_open (__pid_t __pid, unsigned int __flags) __THROW;
+
+#endif /* _PIDFD_H  */
index c93c0d8193853801d5fc33ec98b0a8035a340c05..296dccbcb07f85ca01180f7d62c877b0fe819d8c 100644 (file)
@@ -39,6 +39,7 @@ munlock               -       munlock         i:aU    munlock
 munlockall     -       munlockall      i:      munlockall
 nfsservctl     EXTRA   nfsservctl      i:ipp   __compat_nfsservctl     nfsservctl@GLIBC_2.0:GLIBC_2.28
 pipe2          -       pipe2           i:fi    __pipe2         pipe2
+pidfd_open     EXTRA   pidfd_open      i:iU    pidfd_open
 pivot_root     EXTRA   pivot_root      i:ss    pivot_root
 query_module   EXTRA   query_module    i:sipip __compat_query_module   query_module@GLIBC_2.0:GLIBC_2.23
 quotactl       EXTRA   quotactl        i:isip  quotactl
diff --git a/sysdeps/unix/sysv/linux/tst-pidfd-consts.py b/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
new file mode 100644 (file)
index 0000000..795621b
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/python3
+# Test that glibc's sys/pidfd.h constants match the kernel's.
+# Copyright (C) 2022 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
+
+import argparse
+import sys
+
+import glibcextract
+import glibcsyscalls
+
+
+def main():
+    """The main entry point."""
+    parser = argparse.ArgumentParser(
+        description="Test that glibc's sys/pidfd.h constants "
+        "match the kernel's.")
+    parser.add_argument('--cc', metavar='CC',
+                        help='C compiler (including options) to use')
+    args = parser.parse_args()
+
+    linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
+    linux_version_glibc = (5, 16)
+    sys.exit(glibcextract.compare_macro_consts(
+                '#include <sys/pidfd.h>\n',
+                '#include <asm/fcntl.h>\n'
+                '#include <linux/pidfd.h>\n',
+                args.cc,
+                'PIDFD_.*',
+                None,
+                linux_version_glibc > linux_version_headers,
+                linux_version_headers > linux_version_glibc))
+
+if __name__ == '__main__':
+    main()
index e88b0f101f788eeee19daeef399e9eb50711afc9..0148a68853657e84292f2623a4fb854aa50c8d6b 100644 (file)
@@ -2525,6 +2525,7 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
index e0755272eb62bec3e01db9538289e51227a2f208..0efc2676c32f823158d3403505ac881c2903d6ea 100644 (file)
@@ -2631,3 +2631,4 @@ GLIBC_2.35 __memcmpeq F
 GLIBC_2.35 _dl_find_object F
 GLIBC_2.35 epoll_pwait2 F
 GLIBC_2.35 posix_spawn_file_actions_addtcsetpgrp_np F
+GLIBC_2.36 pidfd_open F