pidfd_getfd on x64
obtain a duplicate of another process's file descriptor
sys_pidfd_getfd(int pidfd, int fd, unsigned int flags)
| number | 438 (0x1b6) |
|---|---|
| abi | common |
| entry point | sys_pidfd_getfd |
| since | Linux 5.6 |
| man page | pidfd_getfd(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 438, the syscall number |
rdi | int pidfd |
rsi | int fd |
rdx | unsigned int flags |
rax | the return value |
Then run syscall to enter the kernel.
The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).
Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.
Same syscall on other architectures
- x86 438
- arm64 438
- arm 438
- riscv64 438
- ia32 438
- x32 1073742262
- loongarch64 438
- ppc64 438
- ppc 438
- s390x 438
- mips64 5438
- mipsn32 6438
- mipso32 4438
- alpha 548
- arc 438
- csky 438
- hexagon 438
- ia64 1462, removed in 6.7
- m68k 438
- microblaze 438
- nds32 438, removed in 5.18
- nios2 438
- openrisc 438
- parisc 438
- sh 438
- sparc 438
- sparc64 438
- xtensa 438
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/pidfd_getfd