1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2005, 2014, 2020 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 18:05:30 1993 by Rik Faith <faith@cs.unc.edu>
11 .\" Modified Fri Feb 16 14:25:17 1996 by Andries Brouwer <aeb@cwi.nl>
12 .\" Modified Sun Jul 21 20:55:44 1996 by Andries Brouwer <aeb@cwi.nl>
13 .\" Modified Mon Oct 15 21:16:25 2001 by John Levon <moz@compsoc.man.ac.uk>
14 .\" Modified Tue Oct 16 00:04:43 2001 by Andries Brouwer <aeb@cwi.nl>
15 .\" Modified Fri Jun 20 03:04:30 2003 by Andries Brouwer <aeb@cwi.nl>
16 .\" 2005-12-13, mtk, Substantial rewrite of strerror_r() description
17 .\" Addition of extra material on portability and standards.
19 .TH STRERROR 3 2021-03-22 "Linux man-pages (unreleased)"
21 strerror, strerrorname_np, strerrordesc_np, strerror_r, strerror_l \-
22 return string describing error number
25 .RI ( libc ", " \-lc )
28 .B #include <string.h>
30 .BI "char *strerror(int " errnum );
31 .BI "const char *strerrorname_np(int " errnum );
32 .BI "const char *strerrordesc_np(int " errnum );
34 .BI "int strerror_r(int " errnum ", char *" buf ", size_t " buflen );
37 .BI "char *strerror_r(int " errnum ", char *" buf ", size_t " buflen );
40 .BI "char *strerror_l(int " errnum ", locale_t " locale );
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
48 .BR strerrorname_np (),
49 .BR strerrordesc_np ():
56 The XSI-compliant version is provided if:
57 (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE
58 Otherwise, the GNU-specific version is provided.
63 function returns a pointer to a string that describes the error
64 code passed in the argument
68 part of the current locale to select the appropriate language.
73 the returned description will be "Invalid argument".)
74 This string must not be modified by the application, but may be
75 modified by a subsequent call to
79 No other library function, including
81 will modify this string.
86 .BR strerrordesc_np ()
87 function returns a pointer to a string that describes the error
88 code passed in the argument
90 with the difference that the returned string is not translated
91 according to the current locale.
94 .BR strerrorname_np ()
95 function returns a pointer to a string containing the name of the error
96 code passed in the argument
100 as an argument, this function returns a pointer to the string "EPERM".
105 function is similar to
109 This function is available in two versions:
110 an XSI-compliant version specified in POSIX.1-2001
111 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
112 and a GNU-specific version (available since glibc 2.0).
113 The XSI-compliant version is provided with the feature test macros
114 settings shown in the SYNOPSIS;
115 otherwise the GNU-specific version is provided.
116 If no feature test macros are explicitly defined,
117 then (since glibc 2.4)
119 is defined by default with the value
120 200112L, so that the XSI-compliant version of
122 is provided by default.
126 is preferred for portable applications.
127 It returns the error string in the user-supplied buffer
134 returns a pointer to a string containing the error message.
135 This may be either a pointer to a string that the function stores in
137 or a pointer to some (immutable) static string
141 If the function stores a string in
145 bytes are stored (the string may be truncated if
150 The string always includes a terminating null byte (\(aq\e0\(aq).
158 to a locale-dependent error message in the locale specified by
164 is the special locale object
166 or is not a valid locale object handle.
174 the appropriate error description string,
175 or an "Unknown error nnn" message if the error number is unknown.
178 .BR strerrorname_np ()
180 .BR strerrordesc_np ()
181 return the appropriate error description string.
184 is an invalid error number, these functions return NULL.
188 function returns 0 on success.
190 a (positive) error number is returned (since glibc 2.13),
191 or \-1 is returned and
193 is set to indicate the error (glibc versions before 2.13).
195 POSIX.1-2001 and POSIX.1-2008 require that a successful call to
201 unchanged, and note that,
202 since no function return value is reserved to indicate an error,
203 an application that wishes to check for errors should initialize
205 to zero before the call,
214 is not a valid error number.
217 Insufficient storage was supplied to contain the error description string.
221 function first appeared in glibc 2.6.
224 .BR strerrorname_np ()
226 .BR strerrordesc_np ()
227 functions first appeared in glibc 2.32.
229 For an explanation of the terms used in this section, see
237 Interface Attribute Value
241 MT-Unsafe race:strerror
244 .BR strerrorname_np (),
245 .BR strerrordesc_np ()
246 T} Thread safety MT-Safe
250 T} Thread safety MT-Safe
257 is specified by POSIX.1-2001, POSIX.1-2008, C89, and C99.
259 is specified by POSIX.1-2001 and POSIX.1-2008.
260 .\" FIXME . for later review when Issue 8 is one day released...
261 .\" A future POSIX.1 may remove strerror_r()
262 .\" http://austingroupbugs.net/tag_view_page.php?tag_id=8
263 .\" http://austingroupbugs.net/view.php?id=508
266 is specified in POSIX.1-2008.
268 The GNU-specific functions
270 .BR strerrorname_np (),
272 .BR strerrordesc_np ()
273 are nonstandard extensions.
279 if the call encounters an error, but does not specify what
280 value should be returned as the function result in the event of an error.
282 .\" e.g., Solaris 8, HP-UX 11
284 returns NULL if the error number is unknown.
286 .\" e.g., FreeBSD 5.4, Tru64 5.1B
288 returns a string something like "Error nnn occurred" and sets
292 if the error number is unknown.
293 C99 and POSIX.1-2008 require the return value to be non-NULL.
295 The GNU C Library uses a buffer of 1024 characters for
297 This buffer size therefore should be sufficient to avoid an
302 .BR strerrorname_np ()
304 .BR strerrordesc_np ()
305 are thread-safe and async-signal-safe.