The Curious Limitation of errno(3) in Linux

2025-07-04

The Linux errno(3) man page reveals a peculiar limitation: errno can be modified even on successful function calls, and it's never set to zero by any system call or library function. This stems from traditional Unix design where system calls typically return errno only on failure, leaving it unchanged on success. C library functions might make multiple system calls, some of which could fail without affecting the library function's overall success, leaving errno with the failure value. ANSI C and POSIX inherited this behavior, requiring errno to be meaningful only when a function fails and its documentation specifies setting errno.

Development