pidfd_show_fdinfo(9)
π pidfd_show_fdinfo(9) π
okay so bestie, welcome to the Kernel API Manual β this page is literally called pidfd_show_fdinfo, and it's the glow-up you needed for peeking inside a pidfd π
β¨ NAME β¨
pidfd_show_fdinfo β print information about a pidfd
πΈ SYNOPSIS πΈ
void pidfd_show_fdinfo (struct seq_file *m , struct file *f );
π¦ ARGUMENTS π¦
mβ the proc fdinfo filefβ a file referencing a pidfd
π DESCRIPTION π
π
Pid
So this function prints the pid that a given pidfd refers to, in the pid namespace of the procfs instance. Slay β¨
BUT β and this is the plot twist β if the pid namespace of the process is not a descendant of the pid namespace of the procfs instance, 0 will be shown as its pid. It's giving the same energy as calling getppid on a process whose parent is outside of its pid namespace. π
π NSpid
If pid namespaces are supported then this function will also print the pid of a given pidfd refers to for all descendant pid namespaces starting from the current pid namespace of the instance, i.e. the Pid field and the first entry in the NSpid field will be identical. iconic behaviour, no cap.
If the pid namespace of the process is not a descendant of the pid namespace of the procfs instance, 0 will be shown as its first NSpid entry and no others will be shown.
π«Ά Heads up bestie β this differs from thePidandNSpidfields in/proc/<pid>/status, wherePidandNSpidare always shown relative to the pid namespace of the procfs instance. The difference becomes obvious when sending around a pidfd between pid namespaces from a different branch of the tree, i.e. where no ancestral relation is present between the pid namespaces:
- create two new pid namespaces
ns1andns2in the initial pid namespace (also take care to create new mount namespaces in the new pid namespace and mount procfs) - create a process with a pidfd in
ns1 - send pidfd from
ns1tons2 - read
/proc/self/fdinfo/<pidfd>and observe that bothPidandNSpidhave exactly one entry, which is0
I know. shook. π
π SEE ALSO π
- Kernel file
./fs/pidfs.cpidfs_register_pid_gfp(9)
π and that's the whole vibe check! This one lives in ./fs, dated October 2026 β so go forth, read those fdinfo files, and stan pid namespaces responsibly π§ββοΈβ¨ periodt.
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms