close_range on x64
close all file descriptors in a given range
sys_close_range(unsigned int fd, unsigned int max_fd, unsigned int flags)
| number | 436 (0x1b4) |
|---|---|
| abi | common |
| entry point | sys_close_range |
| since | Linux 5.9 |
| man page | close_range(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 436, the syscall number |
rdi | unsigned int fd |
rsi | unsigned int max_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 436
- arm64 436
- arm 436
- riscv64 436
- ia32 436
- x32 1073742260
- loongarch64 436
- ppc64 436
- ppc 436
- s390x 436
- mips64 5436
- mipsn32 6436
- mipso32 4436
- alpha 546
- arc 436
- csky 436
- hexagon 436
- ia64 1460, removed in 6.7
- m68k 436
- microblaze 436
- nds32 436, removed in 5.18
- nios2 436
- openrisc 436
- parisc 436
- sh 436
- sparc 436
- sparc64 436
- xtensa 436
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/close_range