Pidfd: Difference between revisions
| (4 intermediate revisions by the same user not shown) | |||
| Line 15: | Line 15: | ||
As of 6.5, credentials can be sent using pidfds rather than <tt>SCM_CREDENTIALS</tt>-style PIDs using the <tt>SCM_PIDFD</tt> type. <tt>getsockopt(2)</tt> can use <tt>SO_PEERPIDFD</tt> to get a pidfd for the peer process on a <tt>unix(7)</tt> socket. | As of 6.5, credentials can be sent using pidfds rather than <tt>SCM_CREDENTIALS</tt>-style PIDs using the <tt>SCM_PIDFD</tt> type. <tt>getsockopt(2)</tt> can use <tt>SO_PEERPIDFD</tt> to get a pidfd for the peer process on a <tt>unix(7)</tt> socket. | ||
6.9 introduces pidfdfs, a pseudo filesystem similar to nsfs. This is not visible from userspace, and is not mounted. It facilitates system calls which demand a filesystem backing: <tt>statx()</tt> now works, as do LSMs (Linux Security Modules). | |||
==[[Glibc]]== | ==[[Glibc]]== | ||
GNU libc added pidfd system call support in 2.36. Glibc 2.39 added two functions for pidfds, complementing <tt>posix_spawn(3)</tt>. They return pidfds rather than PIDs: | GNU libc added pidfd system call support in 2.36. Glibc 2.39 added two functions for pidfds, complementing <tt>posix_spawn(3)</tt>. They return pidfds rather than PIDs: | ||
* <tt>pidfd_spawn(3)</tt>:analogous to <tt>posix_spawn(3)</tt> | * <tt>pidfd_spawn(3)</tt>: analogous to <tt>posix_spawn(3)</tt> | ||
* <tt>pidfd_spawnp(3)</tt>: analogous to <tt>posix_spawnp(3)</tt> | * <tt>pidfd_spawnp(3)</tt>: analogous to <tt>posix_spawnp(3)</tt> | ||
| Line 27: | Line 29: | ||
* <tt>pid_t pidfd_getpid(3)</tt>: get the PID from a pidfd | * <tt>pid_t pidfd_getpid(3)</tt>: get the PID from a pidfd | ||
== | ==External links== | ||
* [https://lwn.net/Articles/943022/ Race-free process creation in the GNU C library], LWN | |||
* [https://lwn.net/Articles/943022/ GNU C Library version 2.39], LWN | |||
* [https://lwn.net/Articles/963749/ A new filesystem for pidfds], LWN | |||
[[Category: Linux]] | [[Category: Linux]] | ||