Errno
errno is a C library macro identifying a modifiable integer error indicator associated with the current thread or execution context.
Modern C, Third Edition
errno is a C library-provided modifiable object or macro designating an integer error indicator associated with the current thread or execution context.
- How it is used
- Supports C library error detection, diagnosis, recovery, and cleanup around operations that may fail.
- How deep it goes
- Explains error-state use, resetting, preservation, and portability constraints, but defers detailed thread semantics and implementation internals.
- Examples
- Uses puts with EOF and perror, puts_safe with reset state, and fprintnumbers with saved errno and cleanup.
- What you can do after
- Diagnose library failures, preserve error state during cleanup, and reset errno after handled recovery.
Modern C
errno is a C standard library macro identifying the thread-local integer error indicator set by library functions.
- How it is used
- Supports C library error checking by recording specific failure conditions alongside function return values.
- How deep it goes
- Explains errno's role, perror's dependence on it, state resetting, and assignments in a strtoul implementation.
- Examples
- Uses puts with EOF, perror, and exit, then implements strtoul overflow and invalid-base handling.
- What you can do after
- Diagnose library failures with return-value checks, perror, and errno values such as ERANGE and EINVAL.
Rust in Action: Systems programming concepts and techniques
errno is a C and POSIX process-global error indicator that system calls may set to identify a failure condition.
- How it is used
- Uses a global error code to signal failures from system calls such as read() and close().
- How deep it goes
- Explains return-value checking, symbolic failure codes, and global-state drawbacks without developing POSIX internals.
- Examples
- Uses read() and close(), with EINTR and EIO illustrating interruption and input/output failure.
- What you can do after
- Diagnose system-call failures by checking a global error value after an operation returns.
Read how Rust in Action: Systems programming concepts and techniques explains errno →
What to know first
- EOFEOF is the condition or signal indicating that no further input is available from a file or stream.
Related concepts
- perrorused by · perror is a C standard library function that writes a diagnostic message describing the error indicated by errno to the standard error stream.
- closeused by · Close is an operation that ends active use of an associated resource or interface and may release or finalize related resources or pending work.
- exceptionused by · An exception is a runtime signal or condition representing an abnormal event that interrupts or alters ordinary program flow and can be handled or propagated.
- failurealternative to · A failure is an event or condition in which a system, component, or operation does not achieve its intended function or expected result.
- strtoulused by · strtoul is a C standard library function that converts the initial portion of a string to an unsigned long value using a specified or inferred integer base.
Questions about errno
What is errno?
errno is a C library macro identifying a modifiable integer error indicator associated with the current thread or execution context.
Which Manning books explain errno?
Modern C, Third Edition, Modern C and Rust in Action: Systems programming concepts and techniques.
What should I know before learning errno?
Manning books that teach errno usually introduce EOF first.
What is the difference between errno and failure?
errno is a C library macro identifying a modifiable integer error indicator associated with the current thread or execution context. A failure is an event or condition in which a system, component, or operation does not achieve its intended function or expected result.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


