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.375
1 files changed, 52 insertions, 23 deletions
diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3
index 8b2d32ea75..0d4f084e5e 100644
--- a/src/lib/libc/string/strerror.3
+++ b/src/lib/libc/string/strerror.3
@@ -1,4 +1,7 @@
1.\" $OpenBSD: strerror.3,v 1.15 2017/09/05 03:16:13 schwarze Exp $
2.\"
1.\" Copyright (c) 1980, 1991 Regents of the University of California. 3.\" Copyright (c) 1980, 1991 Regents of the University of California.
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
2.\" All rights reserved. 5.\" All rights reserved.
3.\" 6.\"
4.\" This code is derived from software contributed to Berkeley by 7.\" This code is derived from software contributed to Berkeley by
@@ -29,46 +32,61 @@
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE. 33.\" SUCH DAMAGE.
31.\" 34.\"
32.\" $OpenBSD: strerror.3,v 1.14 2014/11/30 21:21:59 schwarze Exp $ 35.Dd $Mdocdate: September 5 2017 $
33.\"
34.Dd $Mdocdate: November 30 2014 $
35.Dt STRERROR 3 36.Dt STRERROR 3
36.Os 37.Os
37.Sh NAME 38.Sh NAME
38.Nm strerror , 39.Nm strerror ,
40.Nm strerror_l ,
39.Nm strerror_r 41.Nm strerror_r
40.Nd get error message string 42.Nd get error message string
41.Sh SYNOPSIS 43.Sh SYNOPSIS
42.In string.h 44.In string.h
43.Ft char * 45.Ft char *
44.Fn strerror "int errnum" 46.Fn strerror "int errnum"
47.Ft char *
48.Fn strerror_l "int errnum" "locale_t locale"
45.Ft int 49.Ft int
46.Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen" 50.Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen"
47.Sh DESCRIPTION 51.Sh DESCRIPTION
48The 52These functions map the error number
49.Fn strerror
50and
51.Fn strerror_r
52functions map the error number
53.Fa errnum 53.Fa errnum
54to a language-dependent error message string. 54to an error message string.
55.Pp 55.Pp
56.Fn strerror 56.Fn strerror
57returns a string containing a maximum of 57and
58.Fn strerror_l
59return a string containing a maximum of
58.Dv NL_TEXTMAX 60.Dv NL_TEXTMAX
59characters, including the trailing NUL. 61characters, including the trailing NUL.
60This string is not to be modified by the calling program, 62This string is not to be modified by the calling program.
61but may be overwritten by subsequent calls to 63The string returned by
62.Fn strerror . 64.Fn strerror
65may be overwritten by subsequent calls to
66.Fn strerror
67in any thread.
68The string returned by
69.Fn strerror_l
70may be overwritten by subsequent calls to
71.Fn strerror_l
72in the same thread.
63.Pp 73.Pp
64.Fn strerror_r 74.Fn strerror_r
65is a thread safe version of 75is a thread safe version of
66.Fn strerror 76.Fn strerror
67that places the error message in the specified buffer 77that places the error message in the specified buffer
68.Fa strerrbuf . 78.Fa strerrbuf .
79.Pp
80On
81.Ox ,
82the global locale, the thread-specific locale, and the
83.Fa locale
84argument are ignored.
69.Sh RETURN VALUES 85.Sh RETURN VALUES
70.Fn strerror 86.Fn strerror
71returns a pointer to the error message string. 87and
88.Fn strerror_l
89return a pointer to the error message string.
72If an error occurs, the error code is stored in 90If an error occurs, the error code is stored in
73.Va errno . 91.Va errno .
74.Pp 92.Pp
@@ -77,11 +95,16 @@ returns zero upon successful completion.
77If an error occurs, the error code is stored in 95If an error occurs, the error code is stored in
78.Va errno 96.Va errno
79and the error code is returned. 97and the error code is returned.
80.Sh ERRORS 98.Sh ENVIRONMENT
99On other operating systems, the behaviour of
81.Fn strerror 100.Fn strerror
82and 101and
83.Fn strerror_r 102.Fn strerror_r
84may fail if: 103may depend on the
104.Dv LC_MESSAGES
105.Xr locale 1 .
106.Sh ERRORS
107All these functions may fail if:
85.Bl -tag -width Er 108.Bl -tag -width Er
86.It Bq Er EINVAL 109.It Bq Er EINVAL
87.Fa errnum 110.Fa errnum
@@ -91,7 +114,7 @@ The returned error string will consist of an error message that includes
91.El 114.El
92.Pp 115.Pp
93.Fn strerror_r 116.Fn strerror_r
94may fail if: 117may also fail if:
95.Bl -tag -width Er 118.Bl -tag -width Er
96.It Bq Er ERANGE 119.It Bq Er ERANGE
97The error message is larger than 120The error message is larger than
@@ -101,6 +124,7 @@ The message will be truncated to fit.
101.El 124.El
102.Sh SEE ALSO 125.Sh SEE ALSO
103.Xr intro 2 , 126.Xr intro 2 ,
127.Xr newlocale 3 ,
104.Xr perror 3 , 128.Xr perror 3 ,
105.Xr setlocale 3 129.Xr setlocale 3
106.Sh STANDARDS 130.Sh STANDARDS
@@ -109,15 +133,20 @@ The
109function conforms to 133function conforms to
110.St -isoC-99 . 134.St -isoC-99 .
111The 135The
136.Fn strerror_l
137and
112.Fn strerror_r 138.Fn strerror_r
113function conforms to 139functions conform to
114.St -p1003.1-2008 . 140.St -p1003.1-2008 .
115.Sh HISTORY 141.Sh HISTORY
116The 142The
117.Fn strerror 143.Fn strerror
118function first appeared in 144function has been available since
119.Bx 4.3 Reno . 145.Bx 4.3 Reno ,
120The
121.Fn strerror_r 146.Fn strerror_r
122function first appeared in 147since
123.Ox 3.3 . 148.Ox 3.3 ,
149and
150.Fn strerror_l
151since
152.Ox 6.2 .