sys_pidfd_open(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… sys_pidfd_open(9) β€” the Kernel API Manual, bestie edition πŸŽ€

okay so this is <pink>sys_pidfd_open</pink> from the Kernel API Manual, and honestly? it's giving "tiny function, huge main character energy" ✨ let's get into it.

✨ NAME ✨

sys_pidfd_open β€” open a new pid file descriptor, periodt πŸ’…


🌸 SYNOPSIS 🌸

long sys_pidfd_open (pid_t pid , unsigned int flags );

that's it. that's the whole vibe. two little args, one long coming back at you 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • pid β€” the pid you wanna get a pidfd for πŸ’– like, which task are we locking eyes with
  • flags β€” the flags you're passing in πŸŽ€ just hand them over

πŸ‘‘ DESCRIPTION πŸ‘‘

so what this does is create a brand-new pid file descriptor for the task identified by pid, and no cap β€” it's created with the O_CLOEXEC flag already set πŸ”₯

⚠️ important lil caveat bestie: without the PIDFD_THREAD flag, the target task must be a thread-group leader. like, that's not optional. thread-group leader only. iykyk πŸ’€

⭐ RETURN ⭐

  • on success β†’ you get a cloexec pidfd back, slay 🌈
  • on error β†’ a negative errno number comes back 😭 (not me getting a negative number instead of a fd, fr fr)

🧚 SEE ALSO 🧚

go read those too, they're all connected, it's a whole ecosystem bestie πŸ¦‹βœ¨


and that's the page!! sourced from ./kernel, dated October 2026 β€” mwah, bye, go open some pidfds responsibly πŸ’–πŸŽ€πŸ’…

πŸ“¦ where this page comes from