1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2005, Michael Kerrisk <mtk-manpages@gmx.net>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" References consulted:
25 .\" Linux libc source code
26 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\" Modified Sat Jul 24 18:05:30 1993 by Rik Faith <faith@cs.unc.edu>
29 .\" Modified Fri Feb 16 14:25:17 1996 by Andries Brouwer <aeb@cwi.nl>
30 .\" Modified Sun Jul 21 20:55:44 1996 by Andries Brouwer <aeb@cwi.nl>
31 .\" Modified Mon Oct 15 21:16:25 2001 by John Levon <moz@compsoc.man.ac.uk>
32 .\" Modified Tue Oct 16 00:04:43 2001 by Andries Brouwer <aeb@cwi.nl>
33 .\" Modified Fri Jun 20 03:04:30 2003 by Andries Brouwer <aeb@cwi.nl>
34 .\" 2005-12-13, mtk, Substantial rewrite of strerror_r() description
35 .\" Addition of extra material on portability and standards.
37 .TH STRERROR 3 2005-12-13 "" "Linux Programmer's Manual"
39 strerror, strerror_r \- return string describing error number
42 .B #include <string.h>
44 .BI "char *strerror(int " errnum );
46 .BI "char *strerror_r(int " errnum ", char *" buf ", size_t " buflen );
47 /* GNU-specific strerror_r() */
49 .B #define _XOPEN_SOURCE 600
50 .B #include <string.h>
52 .BI "int strerror_r(int " errnum ", char *" buf ", size_t " buflen );
53 /* XSI-compliant strerror_r() */
56 The \fBstrerror\fP() function returns a string describing the error
57 code passed in the argument \fIerrnum\fP, possibly using the LC_MESSAGES
58 part of the current locale to select the appropriate language.
59 This string must not be modified by the application, but may be
60 modified by a subsequent call to \fBperror\fP() or \fBstrerror\fP().
61 No library function will modify this string.
63 The \fBstrerror_r\fP() function is similar to \fBstrerror\fP(), but is
65 This function is available in two versions:
66 an XSI-compliant version specified in POSIX.1-2001,
67 and a GNU-specific version (available since glibc 2.0).
68 If _XOPEN_SOURCE is defined with the value 600,
69 then the XSI-compliant version is provided,
70 otherwise the GNU-specific version is provided.
74 is preferred for portable applications.
75 It returns the error string in the user-supplied buffer
82 returns a pointer to a string containing the error message.
83 This may be either a pointer to a string that the function stores in
85 or a pointer to some (immutable) static string
89 If the function stores a string in
93 bytes are stored (the string may be truncated if
95 is too small) and the string always includes a terminating null byte.
97 The \fBstrerror\fP() and \fBstrerror_r\fP() functions return
98 the appropriate error description string,
99 or an "Unknown error nnn" message if the error number is unknown.
101 The XSI-compliant \fBstrerror_r\fP() function returns 0 on success;
102 on error, \-1 is returned and
104 is set to indicate the error.
110 is not a valid error number.
113 Insufficient storage was supplied to contain the error description string.
115 \fBstrerror\fP() is specified by POSIX.1-2001, C89, C99.
116 \fBstrerror_r\fP() is specified by POSIX.1-2001.
120 function is a non-standard extension.
126 if the call encounters an error, but does not specify what
127 value should be returned as the function result in the event of an error.
129 .\" e.g., Solaris 8, HP-UX 11
131 returns NULL if the error number is unknown.
133 .\" e.g., FreeBSD 5.4, Tru64 5.1B
135 returns a string something like "Error nnn occurred" and sets
139 if the error number is unknown.
146 .BR feature_test_macros (7)