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.382
1 files changed, 69 insertions, 13 deletions
diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3
index c9d8504dbb..f3f80432c3 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,12 +29,11 @@
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.10 2011/07/25 00:38:53 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: July 25 2011 $
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
44.Nd get error message string 39.Nd get error message string
@@ -46,15 +41,63 @@
46.Fd #include <string.h> 41.Fd #include <string.h>
47.Ft char * 42.Ft char *
48.Fn strerror "int errnum" 43.Fn strerror "int errnum"
44.Ft int
45.Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen"
49.Sh DESCRIPTION 46.Sh DESCRIPTION
50The 47The
51.Fn strerror 48.Fn strerror
52function returns a pointer to the language-dependent error message 49and
53string affiliated with an error number. 50.Fn strerror_r
51functions map the error number
52.Fa errnum
53to a language-dependent error message string.
54.Pp 54.Pp
55The array pointed to is not to be modified by the program, but may be 55.Fn strerror
56overwritten by subsequent calls to 56returns a string containing a maximum of
57.Dv NL_TEXTMAX
58characters, including the trailing NUL.
59This string is not to be modified by the calling program,
60but may be overwritten by subsequent calls to
57.Fn strerror . 61.Fn strerror .
62.Pp
63.Fn strerror_r
64is a thread safe version of
65.Fn strerror
66that places the error message in the specified buffer
67.Fa strerrbuf .
68.Sh RETURN VALUES
69.Fn strerror
70returns a pointer to the error message string.
71If an error occurs, the error code is stored in
72.Va errno .
73.Pp
74.Fn strerror_r
75returns zero upon successful completion.
76If an error occurs, the error code is stored in
77.Va errno
78and the error code is returned.
79.Sh ERRORS
80.Fn strerror
81and
82.Fn strerror_r
83may fail if:
84.Bl -tag -width Er
85.It Bq Er EINVAL
86.Fa errnum
87is not a valid error number.
88The returned error string will consist of an error message that includes
89.Fa errnum .
90.El
91.Pp
92.Fn strerror_r
93may fail if:
94.Bl -tag -width Er
95.It Bq Er ERANGE
96The error message is larger than
97.Fa buflen
98characters.
99The message will be truncated to fit.
100.El
58.Sh SEE ALSO 101.Sh SEE ALSO
59.Xr intro 2 , 102.Xr intro 2 ,
60.Xr perror 3 , 103.Xr perror 3 ,
@@ -64,3 +107,16 @@ The
64.Fn strerror 107.Fn strerror
65function conforms to 108function conforms to
66.St -ansiC . 109.St -ansiC .
110The
111.Fn strerror_r
112function conforms to
113.St -p1003.1 .
114.Sh HISTORY
115The
116.Fn strerror
117function first appeared in
118.Bx 4.3 Reno .
119The
120.Fn strerror_r
121function first appeared in
122.Ox 3.3 .