close on x64
close a file descriptor
sys_close(unsigned int fd)
| number | 3 (0x3) |
|---|---|
| abi | common |
| entry point | sys_close |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | close(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 3, the syscall number |
rdi | unsigned int fd |
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 6
- arm64 57
- arm 6
- riscv64 57
- ia32 6
- x32 1073741827
- loongarch64 57
- ppc64 6
- ppc 6
- s390x 6
- mips64 5003
- mipsn32 6003
- mipso32 4006
- alpha 6
- arc 57
- blackfin 6, removed in 4.17
- cris 6, removed in 4.17
- csky 57
- frv 6, removed in 4.17
- hexagon 57
- ia64 1029, removed in 6.7
- m32r 6, removed in 4.17
- m68k 6
- metag 57, removed in 4.17
- microblaze 6
- mn10300 6, removed in 4.17
- nds32 57, removed in 5.18
- nios2 57
- openrisc 57
- parisc 6
- score 57, removed in 4.17
- sh 6
- sparc 6
- sparc64 6
- tilegx 57, removed in 4.17
- tilepro 57, removed in 4.17
- xtensa 9
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/close