Linux system calls, the kernel boundary
Every time a program reads a file, allocates memory, spawns a process or opens a socket, it crosses from user space into the kernel through a system call. On x86-64, the syscall number goes in the rax register, arguments in rdi, rsi, rdx, r10, r8, r9, and the syscall instruction transfers control to the kernel. This reference lists the most common syscalls with their number, C signature and category so you can decode an strace log or write inline assembly without leaving the page.
How it works
A syscall is dispatched by number. The kernel’s syscall table maps rax to a handler, the handler runs in kernel mode, and the result comes back in rax. At the raw level a return value in the range -4095 to -1 is a negated errno — the glibc wrapper detects this, returns -1 and sets errno to the positive code. Successful calls return a non-negative value: a count of bytes, a new file descriptor, a pointer (from mmap), or 0.
Syscalls group into families. Process calls (fork, clone, execve, exit_group, wait4) manage the process lifecycle. File calls (open/openat, read, write, close, lseek, stat) move data through file descriptors. Memory calls (mmap, munmap, mprotect, brk) manage the address space. Network calls (socket, bind, listen, accept, connect, sendto, recvfrom) drive sockets. Signal calls (kill, rt_sigaction, rt_sigprocmask) deliver and handle asynchronous notifications.
Tips and examples
- Prefer the
*atvariants (openat,unlinkat,fstatat) for race-free path resolution relative to a directory file descriptor. strace -c ./proggives a histogram of which syscalls dominate — useful when a program feels slow or chatty.- The numbers here are x86-64 specific. The canonical table lives at
arch/x86/entry/syscalls/syscall_64.tblin the kernel source.