pidfd_show_fdinfo(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 file
  • f β€” 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 the Pid and NSpid fields in /proc/<pid>/status, where Pid and NSpid are 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:
  1. create two new pid namespaces ns1 and ns2 in the initial pid namespace (also take care to create new mount namespaces in the new pid namespace and mount procfs)
  2. create a process with a pidfd in ns1
  3. send pidfd from ns1 to ns2
  4. read /proc/self/fdinfo/<pidfd> and observe that both Pid and NSpid have exactly one entry, which is 0

I know. shook. πŸ’€


🌈 SEE ALSO 🌈


πŸ’– 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