getpid on x64
get process identification
sys_getpid(void)
| number | 39 (0x27) |
|---|---|
| abi | common |
| entry point | sys_getpid |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | getpid(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 39, the syscall number |
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 20
- arm64 172
- arm 20
- riscv64 172
- ia32 20
- x32 1073741863
- loongarch64 172
- ppc64 20
- ppc 20
- s390x 20
- mips64 5038
- mipsn32 6038
- mipso32 4020
- arc 172
- blackfin 20, removed in 4.17
- cris 20, removed in 4.17
- csky 172
- frv 20, removed in 4.17
- hexagon 172
- ia64 1041, removed in 6.7
- m32r 20, removed in 4.17
- m68k 20
- metag 172, removed in 4.17
- microblaze 20
- mn10300 20, removed in 4.17
- nds32 172, removed in 5.18
- nios2 172
- openrisc 172
- parisc 20
- score 172, removed in 4.17
- sh 20
- sparc 20
- sparc64 20
- tilegx 172, removed in 4.17
- tilepro 172, removed in 4.17
- xtensa 120
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/getpid