# Pidfd\_getfd() syscall

**URL:** <https://discuss.python.org/t/pidfd-getfd-syscall/107203>\
**Category:** Ideas\
**Created:** [May 5, 2026, 10:01pm UTC](https://discuss.python.org/t/pidfd-getfd-syscall/107203 "2026-05-05T22:01:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maurycy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/maurycy/32/29781_2.png) [@maurycy](https://discuss.python.org/u/maurycy)\
**Post date:** [May 5, 2026, 10:01pm UTC](https://discuss.python.org/t/pidfd-getfd-syscall/107203/1 "2026-05-05T22:01:18Z")

</div>

Any particular reason why we don’t support `pidfd_getfd()` syscall?

`os.pidfd_open` and `signal.pidfd_send_signal` exist, so it looks like an simple omission.

There was a thread 4 years ago that got two upvotes but didn’t get anywhere:

> [@Add pidfd\_getfd syscall to \`os\` module](https://discuss.python.org/t/add-pidfd-getfd-syscall-to-os-module/19789):
>
> Since Linux 5.6 we have [pidfd\_getfd](https://man7.org/linux/man-pages/man2/pidfd_getfd.2.html) which is quite a close cousin to [already supported in Python pidfd\_open](https://github.com/python/cpython/issues/82873). Let me know if you think it’s a good idea slight_smile BR, Patryk

People just hijack it with `ctypes` right now. Quick findings from Github:

> <https://github.com/raspberrypi/picamera2/blob/e1511e1d11c2bafac5dfdd1c377fe1fce1885a5b/picamera2/remote.py#L151-L157>

> <https://github.com/NVIDIA/TensorRT-LLM/blob/db3a93f9241ad807b113f472be2d53c096145b1e/tensorrt_llm/_mnnvl_utils.py#L230-L252>

> <https://github.com/EdgeFirstAI/samples/blob/99a0199d12ddf88c2057c5b6e2229787ece82a98/python/camera/dma.py#L17-L70>

I can do a PR immediately if there’s interest.

---

<div class="post-metadata">

**Author:** ![vstinner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/vstinner/32/15130_2.png) [@vstinner](https://discuss.python.org/u/vstinner)\
**Post date:** [May 6, 2026, 2:48pm UTC](https://discuss.python.org/t/pidfd-getfd-syscall/107203/2 "2026-05-06T14:48:44Z")

</div>

Adding `os.pidfd_getfd(pidfd, targetfd, flags=0)` sounds like a reasonable addition. `FD_CLOEXEC` should be used by default to respect [PEP 446](https://peps.python.org/pep-0446/). The tricky part is to write good documentation and write tests.

> [@maurycy](#):
>
> Any particular reason why we don’t support `pidfd_getfd()` syscall?

Well, so far, nobody opened an issue to propose adding this function to Python stdlib.

---

<div class="post-metadata">

**Author:** ![vstinner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/vstinner/32/15130_2.png) [@vstinner](https://discuss.python.org/u/vstinner)\
**Post date:** [May 18, 2026, 2:33pm UTC](https://discuss.python.org/t/pidfd-getfd-syscall/107203/3 "2026-05-18T14:33:44Z")

</div>

**Update** : the function was just added to Python 3.16: [commit](https://github.com/python/cpython/commit/a2932e9c95640cb98828f3e78545afacf78776f5). It’s the first new function of Python 3.16 🙂 Thanks Maurycy Pawłowski-Wieroński for your contribution!
