errno
errno is a macro used in C and POSIX-like environments to indicate the error status of the most recently invoked library or system call. It expands to a modifiable lvalue of type int and is typically defined in errno.h. In multithreaded programs, errno is thread-local, so each thread maintains its own error value.
When a function returns an error (commonly -1 for many system calls), it may set errno to
The exact set of error codes is implementation-defined, but many common codes are standardized by POSIX, such
Values of errno are not guaranteed to be zero on success; some functions do not modify errno