ERRNO(3P)
โจ ERRNO(3P) โจ
okay bestie so this is the POSIX Programmer's Manual page for errno, and literally the first thing you need to know is that this page is part of the POSIX Programmer's Manual. that's the whole vibe. but heads up ๐ซถ โ the Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for the details of Linux behavior), or honestly the interface may not be implemented on Linux at all. not me being dramatic, that's just what it says ๐
๐ PROLOG ๐
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
๐ธ NAME ๐ธ
errno โ error return value. that's it. that's the whole name section. iconic behavior tbh ๐
๐ SYNOPSIS ๐
#include <errno.h>
๐ฆ DESCRIPTION ๐ฆ
so the lvalue errno is used by many functions to return error values. like, it's the group chat where every function drops its bad news ๐ฌ
Many functions provide an error number in errno, which has type int and is defined in <errno.h>. got it? int. not a long, not a size_t, int. periodt ๐
now the rules, and bestie you HAVE to follow these:
- The value of
errnoshall be defined only after a call to a function for which it is explicitly stated to be set, and it stays defined until it is changed by the next function call โ or until the application assigns it a value. - The value of
errnoshould only be examined when it is indicated to be valid by a function's return value. no peeking when it's not invited ๐ - Applications shall obtain the definition of
errnoby the inclusion of<errno.h>. - No function in this volume of POSIX.1โ2017 shall set
errnoto 0. like, zero is just not on the menu. - The setting of
errnoafter a successful call to a function is unspecified unless the description of that function specifies thaterrnoshall not be modified. so don't be out here reading it after a win and assuming it means something, that's a whole vibe check fail ๐ญ
okay and this next part is the spicy one ๐ถ๏ธ
It is unspecified whethererrnois a macro or an identifier declared with external linkage. If a macro definition is suppressed in order to access an actual object, or a program defines an identifier with the nameerrno, the behavior is undefined. undefined. undefinED. don't do it, bestie, I'm begging ๐ซถ
The symbolic values stored in errno are documented in the ERRORS sections on all relevant pages. so if you want the tea on what a specific number means, that's where it lives ๐
๐ RETURN VALUE ๐
None. absolutely nothing. it's giving void energy โญ
๐ ERRORS ๐
None.
The following sections are informative. (translation: the rest of this page is the commentary track, not the rules ๐ง)
๐ EXAMPLES ๐
None. no examples, no demo, no tutorial arc, we simply do not have one today ๐
๐ง APPLICATION USAGE ๐ง
history lesson time โจ Previously both POSIX and X/Open documents were more restrictive than the ISO C standard in that they required errno to be defined as an external variable, whereas the ISO C standard required only that errno be defined as a modifiable lvalue with type int. so the ISO C girlies were out here being chill and POSIX/X-Open were out here being strict. the way that standards evolve ๐
and here's the actual practical tip, write it down ๐ โ an application that needs to examine the value of errno to determine the error should set it to 0 before a function call, then inspect it before a subsequent function call.
like literally:
errno = 0;
some_function_call();
/* inspect errno now, before calling anything else */
because remember, the next function call can just wipe it. it's giving "you snooze you lose" ๐
๐ RATIONALE ๐
None. the reasoning is a mystery, the reasoning is a secret, the reasoning said "no thoughts head empty" ๐
โญ FUTURE DIRECTIONS โญ
None. the future is unspecified but it is definitely not doing anything here ๐ฎ
๐ซ SEE ALSO ๐ซ
- Section 2.3, Error Numbers
- The Base Definitions volume of POSIX.1โ2017,
<errno.h>
๐ธ COPYRIGHT ๐ธ
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay bestie that's the whole page, we did it, we read the entire thing ๐ this one's brought to you by IEEE/The Open Group, 2017 โ that's the source and the date, and honestly? slay. now go set your errno to 0 and check it before the next call, I'm so serious ๐ซถ๐โจ
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms