SYSCALL(2)
๐ SYSCALL(2) โ the indirect system call page, bestie edition
okay so this is the syscall(2) page from the System Calls Manual, and honestly? it's a little icon. let's get into it ๐ซถ
โจ NAME โจ
syscall, __syscall โ indirect system call
like, you're calling a syscall indirectly, iykyk ๐ซ
๐ LIBRARY ๐
Standard C Library (libc, -lc)
yep, the classic. the one that's literally always there ๐
๐ธ SYNOPSIS ๐ธ
#include <sys/syscall.h>
#include <unistd.h>
int
syscall(int number, ...);
off_t
__syscall(quad_t number, ...);
two headers, two functions. that's the whole vibe check โจ
๐ DESCRIPTION ๐
okay so the way syscall() works is, it performs the system call whose assembly language interface has the specified number with the specified arguments. that's it, that's the whole thing โ you hand it a number, it goes and does the syscall ๐
Symbolic constants for system calls can be found in the header file <sys/syscall.h. so like, please don't just memorize raw numbers, the constants are right there ๐ง
the __syscall() form should be used when one or more of the arguments is a 64-bit argument to ensure that argument alignment is correct. lowkey important โ misaligned args are not the moment, ngl ๐ญ
this system call is useful for testing new system calls that do not have entries in the C library. so when the libc hasn't caught up yet and you're feeling brave? this is your girl. main character energy fr fr ๐
๐ฅ RETURN VALUES ๐ฅ
the return values are defined by the system call being invoked. like, it's not gonna tell you here, it depends on what you asked for.
in general, a 0 return value indicates success ๐ a -1 return value indicates an error, and an error code is stored in errno. so if you get -1, go check errno, that's where the tea is ๐
๐ฆ HISTORY ๐ฆ
the syscall() function appeared in 4.0BSD. vintage! iconic! ๐
๐ BUGS ๐
there is no way to simulate system calls that have multiple return values such as pipe(2). so like, if a syscall hands back more than one thing? this trick just cannot do it. periodt ๐
okay bestie that's the whole page ๐ huge thanks to the Debian crew for this one โ this version is from Debian, dated June 16, 1993, so it's older than most of your faves and it's still serving ๐ โจ ๐
๐ฆ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1980, 1991, 1993 The Regents of the University of California. All rights reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms