lmao tough shit
System programming
Syscalls are generally not guaranteed to correctly terminate. As a result, most syscalls return a numeric value, with -1 being a failed result. When they return, they also set errno, which we can pass into perror to print a human-readable error message.
static void check(int ret, const char *msg) {
if (ret != -1)
return;
int err = errno;
perror(msg);
exit(err);
}Standard calling code is below. Note how we check in all cases. If the syscall has indeed correctly returned, the check function will do nothing.
int res = syscall();
check(res, "syscall");