diff options
Diffstat (limited to 'src/lib/libc/string/strerror.3')
-rw-r--r-- | src/lib/libc/string/strerror.3 | 82 |
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 |
50 | The | 47 | The |
51 | .Fn strerror | 48 | .Fn strerror |
52 | function returns a pointer to the language-dependent error message | 49 | and |
53 | string affiliated with an error number. | 50 | .Fn strerror_r |
51 | functions map the error number | ||
52 | .Fa errnum | ||
53 | to a language-dependent error message string. | ||
54 | .Pp | 54 | .Pp |
55 | The array pointed to is not to be modified by the program, but may be | 55 | .Fn strerror |
56 | overwritten by subsequent calls to | 56 | returns a string containing a maximum of |
57 | .Dv NL_TEXTMAX | ||
58 | characters, including the trailing NUL. | ||
59 | This string is not to be modified by the calling program, | ||
60 | but may be overwritten by subsequent calls to | ||
57 | .Fn strerror . | 61 | .Fn strerror . |
62 | .Pp | ||
63 | .Fn strerror_r | ||
64 | is a thread safe version of | ||
65 | .Fn strerror | ||
66 | that places the error message in the specified buffer | ||
67 | .Fa strerrbuf . | ||
68 | .Sh RETURN VALUES | ||
69 | .Fn strerror | ||
70 | returns a pointer to the error message string. | ||
71 | If an error occurs, the error code is stored in | ||
72 | .Va errno . | ||
73 | .Pp | ||
74 | .Fn strerror_r | ||
75 | returns zero upon successful completion. | ||
76 | If an error occurs, the error code is stored in | ||
77 | .Va errno | ||
78 | and the error code is returned. | ||
79 | .Sh ERRORS | ||
80 | .Fn strerror | ||
81 | and | ||
82 | .Fn strerror_r | ||
83 | may fail if: | ||
84 | .Bl -tag -width Er | ||
85 | .It Bq Er EINVAL | ||
86 | .Fa errnum | ||
87 | is not a valid error number. | ||
88 | The returned error string will consist of an error message that includes | ||
89 | .Fa errnum . | ||
90 | .El | ||
91 | .Pp | ||
92 | .Fn strerror_r | ||
93 | may fail if: | ||
94 | .Bl -tag -width Er | ||
95 | .It Bq Er ERANGE | ||
96 | The error message is larger than | ||
97 | .Fa buflen | ||
98 | characters. | ||
99 | The 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 |
65 | function conforms to | 108 | function conforms to |
66 | .St -ansiC . | 109 | .St -ansiC . |
110 | The | ||
111 | .Fn strerror_r | ||
112 | function conforms to | ||
113 | .St -p1003.1 . | ||
114 | .Sh HISTORY | ||
115 | The | ||
116 | .Fn strerror | ||
117 | function first appeared in | ||
118 | .Bx 4.3 Reno . | ||
119 | The | ||
120 | .Fn strerror_r | ||
121 | function first appeared in | ||
122 | .Ox 3.3 . | ||