STRERROR(3) | Library Functions Manual | STRERROR(3) |
strerror
,
strerror_l
, strerror_r
— get error message string
#include
<string.h>
char *
strerror
(int
errnum);
char *
strerror_l
(int
errnum, locale_t
locale);
int
strerror_r
(int
errnum, char
*strerrbuf, size_t
buflen);
These functions map the error number errnum to an error message string.
strerror
() and
strerror_l
() return a string containing a maximum of
NL_TEXTMAX
characters, including the trailing NUL.
This string is not to be modified by the calling program. The string
returned by strerror
() may be overwritten by
subsequent calls to strerror
() in any thread. The
string returned by strerror_l
() may be overwritten
by subsequent calls to strerror_l
() in the same
thread.
strerror_r
() is a thread safe version of
strerror
() that places the error message in the
specified buffer strerrbuf.
On OpenBSD, the global locale, the thread-specific locale, and the locale argument are ignored.
strerror
() and
strerror_l
() return a pointer to the error message
string. If an error occurs, the error code is stored in
errno.
strerror_r
() returns zero upon successful
completion. If an error occurs, the error code is stored in
errno and the error code is returned.
All these functions may fail if:
EINVAL
]strerror_r
() may also fail if:
ERANGE
]The strerror
() function conforms to
ISO/IEC 9899:1999 (“ISO C99”).
The strerror_l
() and
strerror_r
() functions conform to
IEEE Std 1003.1-2008 (“POSIX.1”).
The strerror
() function has been available
since 4.3BSD-Reno,
strerror_r
() since OpenBSD
3.3, and strerror_l
() since
OpenBSD 6.2.
On systems other than OpenBSD, the
LC_MESSAGES
locale(1) category can cause different
strings to be returned instead of the normal error messages; see CAVEATS in
setlocale(3) for details.
May 16, 2019 | OpenBSD-current |