SYSCALL(2)

πŸ’– SYSCALL(2) πŸ’–

okay bestie, welcome to the System Calls Manual entry for SYSCALL(2) β€” yes we're going indirect, it's giving ✨middleware energy✨ and honestly? iconic.


🌸 NAME 🌸

syscall, __syscall β€” indirect system call πŸ¦‹


πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) πŸŽ€


✨ SYNOPSIS ✨

#include <sys/syscall.h>
#include <unistd.h>

int
syscall(int number, ...);

off_t
__syscall(quad_t number, ...);

πŸ’… DESCRIPTION πŸ’…

so the way that syscall() works is: it performs the system call whose assembly language interface has the specified number with the specified arguments. fr fr, that's the whole vibe. 🫢

the symbolic constants for system calls can be found in the header file <sys/syscall.h>. go look, they're all in there, no cap. πŸ”₯

now, the __syscall() form should be used when one or more of the arguments is a 64-bit argument β€” that's the one that makes sure your argument alignment is correct. don't skip it, bestie, alignment matters. πŸ’€

and like, what is this even for? this system call is useful for testing new system calls that do not have entries in the C library. it's the VIP backstage pass for syscalls that haven't been officially introduced to libc yet. main character energy for real. πŸ‘‘


🌈 RETURN VALUES 🌈

the return values are defined by the system call being invoked β€” so like, it's not a fixed thing, it depends on which syscall you poked. πŸ™ˆ

in general:

  • a 0 return value indicates success ✨
  • a -1 return value indicates an error, and an error code is stored in errno 😭

πŸ•°οΈ HISTORY πŸ•°οΈ

the syscall() function appeared in 4.0BSD. vintage. antique. historical queen. πŸ‘‘


πŸ› BUGS πŸ›

there is no way to simulate system calls that have multiple return values such as pipe(2). that's it, that's the bug, we're all just living with it. πŸ’€

and that's the whole page, bestie πŸ’– this one came to you from Debian, dated June 16, 1993 β€” yeah it's older than us but it still ate. mwah. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from