sys_pidfd_getfd(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… sys_pidfd_getfd β€” a Kernel API Manual moment πŸŽ€

okay bestie, welcome to the <pink>Kernel API Manual</pink> entry for sys_pidfd_getfd, and trust me, this one is lowkey iconic πŸ¦‹


✨ NAME ✨

sys_pidfd_getfd β€” literally just Get a file descriptor from another process πŸ‘‘

🌸 SYNOPSIS 🌸

long sys_pidfd_getfd (int pidfd , int fd , unsigned int flags );

πŸŽ€ ARGUMENTS πŸŽ€

  • pidfd β€” the pidfd file descriptor of the process 🫢
  • fd β€” the file descriptor number to get (yes, the actual number, no cap) πŸ”’
  • flags β€” flags on how to get the fd, and bestie… they're reserved πŸ™ˆ

πŸ’– DESCRIPTION πŸ’–

so the way this works is: this syscall gets a copy of a file descriptor from another process, based on the pidfd and the file descriptor number. the range! ✨

but here's the vibe check πŸ’… β€” it requires that the calling process has the ability to ptrace the process represented by the pidfd. so no sneaky business, you gotta have the clearance, iykyk.

and the process which is having its file descriptor copied? otherwise unaffected. she doesn't even notice, main character behavior fr fr 🌈

πŸ”₯ RETURN πŸ”₯

On success, a cloexec file descriptor is returned. slay. πŸŽ‰

On error, a negative errno number will be returned 😭 (yes negative, like, emotionally).

🌟 SEE ALSO 🌟

Kernel file ./kernel/pid.c pidfd_get_task(9), pidfd_create(9), sys_pidfd_open(9) β€” go read those next, they're giving lore πŸ§šπŸ’œ


and that's the whole page, bestie! πŸ’… this cutie came from ./kernel, dated October 2026, and she's filed under sys_pidfd_getfd(9) β€” periodt. πŸ“πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from