1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2005, 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 2012-04-22 "" "Linux Programmer's Manual"
41 strerror, strerror_r \- 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 );
56 Feature Test Macro Requirements for glibc (see
57 .BR feature_test_macros (7)):
60 The XSI-compliant version of
64 (_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600) && !\ _GNU_SOURCE
66 Otherwise, the GNU-specific version is provided.
70 function returns a pointer to a string that describes the error
71 code passed in the argument
75 part of the current locale to select the appropriate language.
80 the returned description will "Invalid argument".)
81 This string must not be modified by the application, but may be
82 modified by a subsequent call to
84 No library function, including
86 will modify this string.
90 function is similar to
94 This function is available in two versions:
95 an XSI-compliant version specified in POSIX.1-2001
96 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
97 and a GNU-specific version (available since glibc 2.0).
98 The XSI-compliant version is provided with the feature test macros
99 settings shown in the SYNOPSIS;
100 otherwise the GNU-specific version is provided.
101 If no feature test macros are explicitly defined,
102 then (since glibc 2.4)
104 is defined by default with the value
105 200112L, so that the XSI-compliant version of
107 is provided by default.
111 is preferred for portable applications.
112 It returns the error string in the user-supplied buffer
119 returns a pointer to a string containing the error message.
120 This may be either a pointer to a string that the function stores in
122 or a pointer to some (immutable) static string
126 If the function stores a string in
130 bytes are stored (the string may be truncated if
135 The string always includes a terminating null byte.
142 the appropriate error description string,
143 or an "Unknown error nnn" message if the error number is unknown.
145 POSIX.1-2001 and POSIX.1-2008 require that a successful call to
149 unchanged, and note that,
150 since no function return value is reserved to indicate an error,
151 an application that wishes to check for errors should initialize
153 to zero before the call,
160 function returns 0 on success.
162 a (positive) error number is returned (since glibc 2.13),
163 or \-1 is returned and
165 is set to indicate the error (glibc versions before 2.13).
171 is not a valid error number.
174 Insufficient storage was supplied to contain the error description string.
177 is specified by POSIX.1-2001, C89, C99.
179 is specified by POSIX.1-2001.
183 function is a nonstandard extension.
189 if the call encounters an error, but does not specify what
190 value should be returned as the function result in the event of an error.
192 .\" e.g., Solaris 8, HP-UX 11
194 returns NULL if the error number is unknown.
196 .\" e.g., FreeBSD 5.4, Tru64 5.1B
198 returns a string something like "Error nnn occurred" and sets
202 if the error number is unknown.
203 C99 and POSIX.1-2008 require the return value to be non-NULL.