1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2005, 2014 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" References consulted:
27 .\" Linux libc source code
28 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
30 .\" Modified Sat Jul 24 18:05:30 1993 by Rik Faith <faith@cs.unc.edu>
31 .\" Modified Fri Feb 16 14:25:17 1996 by Andries Brouwer <aeb@cwi.nl>
32 .\" Modified Sun Jul 21 20:55:44 1996 by Andries Brouwer <aeb@cwi.nl>
33 .\" Modified Mon Oct 15 21:16:25 2001 by John Levon <moz@compsoc.man.ac.uk>
34 .\" Modified Tue Oct 16 00:04:43 2001 by Andries Brouwer <aeb@cwi.nl>
35 .\" Modified Fri Jun 20 03:04:30 2003 by Andries Brouwer <aeb@cwi.nl>
36 .\" 2005-12-13, mtk, Substantial rewrite of strerror_r() description
37 .\" Addition of extra material on portability and standards.
39 .TH STRERROR 3 2017-09-15 "" "Linux Programmer's Manual"
41 strerror, strerror_r, strerror_l \- return string describing error number
44 .B #include <string.h>
46 .BI "char *strerror(int " errnum );
48 .BI "int strerror_r(int " errnum ", char *" buf ", size_t " buflen );
51 .BI "char *strerror_r(int " errnum ", char *" buf ", size_t " buflen );
54 .BI "char *strerror_l(int " errnum ", locale_t " locale );
58 Feature Test Macro Requirements for glibc (see
59 .BR feature_test_macros (7)):
65 The XSI-compliant version is provided if:
67 (_POSIX_C_SOURCE\ >=\ 200112L) && ! \ _GNU_SOURCE
69 Otherwise, the GNU-specific version is provided.
75 function returns a pointer to a string that describes the error
76 code passed in the argument
80 part of the current locale to select the appropriate language.
85 the returned description will be "Invalid argument".)
86 This string must not be modified by the application, but may be
87 modified by a subsequent call to
91 No other library function, including
93 will modify this string.
98 function is similar to
102 This function is available in two versions:
103 an XSI-compliant version specified in POSIX.1-2001
104 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
105 and a GNU-specific version (available since glibc 2.0).
106 The XSI-compliant version is provided with the feature test macros
107 settings shown in the SYNOPSIS;
108 otherwise the GNU-specific version is provided.
109 If no feature test macros are explicitly defined,
110 then (since glibc 2.4)
112 is defined by default with the value
113 200112L, so that the XSI-compliant version of
115 is provided by default.
119 is preferred for portable applications.
120 It returns the error string in the user-supplied buffer
127 returns a pointer to a string containing the error message.
128 This may be either a pointer to a string that the function stores in
130 or a pointer to some (immutable) static string
134 If the function stores a string in
138 bytes are stored (the string may be truncated if
143 The string always includes a terminating null byte (\(aq\\0\(aq).
151 to a locale-dependent error message in the locale specified by
157 is the special locale object
159 or is not a valid locale object handle.
167 the appropriate error description string,
168 or an "Unknown error nnn" message if the error number is unknown.
172 function returns 0 on success.
174 a (positive) error number is returned (since glibc 2.13),
175 or \-1 is returned and
177 is set to indicate the error (glibc versions before 2.13).
179 POSIX.1-2001 and POSIX.1-2008 require that a successful call to
185 unchanged, and note that,
186 since no function return value is reserved to indicate an error,
187 an application that wishes to check for errors should initialize
189 to zero before the call,
198 is not a valid error number.
201 Insufficient storage was supplied to contain the error description string.
205 function first appeared in glibc 2.6.
207 For an explanation of the terms used in this section, see
213 Interface Attribute Value
216 T} Thread safety MT-Unsafe race:strerror
221 T} Thread safety MT-Safe
225 is specified by POSIX.1-2001, POSIX.1-2008, C89, and C99.
227 is specified by POSIX.1-2001 and POSIX.1-2008.
228 .\" FIXME . for later review when Issue 8 is one day released...
229 .\" A future POSIX.1 may remove strerror_r()
230 .\" http://austingroupbugs.net/tag_view_page.php?tag_id=8
231 .\" http://austingroupbugs.net/view.php?id=508
234 is specified in POSIX.1-2008.
238 function is a nonstandard extension.
244 if the call encounters an error, but does not specify what
245 value should be returned as the function result in the event of an error.
247 .\" e.g., Solaris 8, HP-UX 11
249 returns NULL if the error number is unknown.
251 .\" e.g., FreeBSD 5.4, Tru64 5.1B
253 returns a string something like "Error nnn occurred" and sets
257 if the error number is unknown.
258 C99 and POSIX.1-2008 require the return value to be non-NULL.
260 The GNU C Library uses a buffer of 1024 characters for
262 This buffer size therefore should be sufficient to avoid an