summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/strerror.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/string/strerror.3')
-rw-r--r--src/lib/libc/string/strerror.389
1 files changed, 73 insertions, 16 deletions
diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3
index c9d8504dbb..264ac39052 100644
--- a/src/lib/libc/string/strerror.3
+++ b/src/lib/libc/string/strerror.3
@@ -13,11 +13,7 @@
13.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the 14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution. 15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software 16.\" 3. Neither the name of the University nor the names of its contributors
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software 17.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission. 18.\" without specific prior written permission.
23.\" 19.\"
@@ -33,28 +29,76 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
35.\" 31.\"
36.\" from: @(#)strerror.3 6.9 (Berkeley) 6/29/91 32.\" $OpenBSD: strerror.3,v 1.13 2014/04/07 17:57:56 schwarze Exp $
37.\" $Id: strerror.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $
38.\" 33.\"
39.Dd June 29, 1991 34.Dd $Mdocdate: April 7 2014 $
40.Dt STRERROR 3 35.Dt STRERROR 3
41.Os BSD 4 36.Os
42.Sh NAME 37.Sh NAME
43.Nm strerror 38.Nm strerror ,
39.Nm strerror_r
44.Nd get error message string 40.Nd get error message string
45.Sh SYNOPSIS 41.Sh SYNOPSIS
46.Fd #include <string.h> 42.In string.h
47.Ft char * 43.Ft char *
48.Fn strerror "int errnum" 44.Fn strerror "int errnum"
45.Ft int
46.Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen"
49.Sh DESCRIPTION 47.Sh DESCRIPTION
50The 48The
51.Fn strerror 49.Fn strerror
52function returns a pointer to the language-dependent error message 50and
53string affiliated with an error number. 51.Fn strerror_r
52functions map the error number
53.Fa errnum
54to a language-dependent error message string.
54.Pp 55.Pp
55The array pointed to is not to be modified by the program, but may be 56.Fn strerror
56overwritten by subsequent calls to 57returns a string containing a maximum of
58.Dv NL_TEXTMAX
59characters, including the trailing NUL.
60This string is not to be modified by the calling program,
61but may be overwritten by subsequent calls to
57.Fn strerror . 62.Fn strerror .
63.Pp
64.Fn strerror_r
65is a thread safe version of
66.Fn strerror
67that places the error message in the specified buffer
68.Fa strerrbuf .
69.Sh RETURN VALUES
70.Fn strerror
71returns a pointer to the error message string.
72If an error occurs, the error code is stored in
73.Va errno .
74.Pp
75.Fn strerror_r
76returns zero upon successful completion.
77If an error occurs, the error code is stored in
78.Va errno
79and the error code is returned.
80.Sh ERRORS
81.Fn strerror
82and
83.Fn strerror_r
84may fail if:
85.Bl -tag -width Er
86.It Bq Er EINVAL
87.Fa errnum
88is not a valid error number.
89The returned error string will consist of an error message that includes
90.Fa errnum .
91.El
92.Pp
93.Fn strerror_r
94may fail if:
95.Bl -tag -width Er
96.It Bq Er ERANGE
97The error message is larger than
98.Fa buflen
99characters.
100The message will be truncated to fit.
101.El
58.Sh SEE ALSO 102.Sh SEE ALSO
59.Xr intro 2 , 103.Xr intro 2 ,
60.Xr perror 3 , 104.Xr perror 3 ,
@@ -63,4 +107,17 @@ overwritten by subsequent calls to
63The 107The
64.Fn strerror 108.Fn strerror
65function conforms to 109function conforms to
66.St -ansiC . 110.St -ansiC-99 .
111The
112.Fn strerror_r
113function conforms to
114.St -p1003.1-2008 .
115.Sh HISTORY
116The
117.Fn strerror
118function first appeared in
119.Bx 4.3 Reno .
120The
121.Fn strerror_r
122function first appeared in
123.Ox 3.3 .