diff options
| author | Wes Peters <wes@FreeBSD.org> | 2001-12-20 06:31:26 +0000 |
|---|---|---|
| committer | Wes Peters <wes@FreeBSD.org> | 2001-12-20 06:31:26 +0000 |
| commit | 0b6d38c427a9bc4123401e283c9255a12701d46a (patch) | |
| tree | b71b6e099a52f19081a81da58f0a9829681760c5 /lib/libc/string/strerror.3 | |
| parent | 933ff66cf7afdccd2d734e467ec887e947fbbe9e (diff) | |
Notes
Diffstat (limited to 'lib/libc/string/strerror.3')
| -rw-r--r-- | lib/libc/string/strerror.3 | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3 index 447e208c39c0..e64e79c4b17e 100644 --- a/lib/libc/string/strerror.3 +++ b/lib/libc/string/strerror.3 @@ -36,12 +36,13 @@ .\" @(#)strerror.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd June 9, 1993 +.Dd Nov 26, 2001 .Dt STRERROR 3 .Os .Sh NAME .Nm perror , .Nm strerror , +.Nm strerror_r , .Nm sys_errlist , .Nm sys_nerr .Nd system error messages @@ -56,9 +57,12 @@ .In string.h .Ft char * .Fn strerror "int errnum" +.Ft int +.Fn strerror_r "int errnum" "char * strerrbuf" "size_t buflen" .Sh DESCRIPTION The -.Fn strerror +.Fn strerror , +.Fn strerror_r and .Fn perror functions look up the error message string corresponding to an @@ -68,11 +72,18 @@ The .Fn strerror function accepts an error number argument .Fa errnum -and -returns a pointer to the corresponding +and returns a pointer to the corresponding message string. .Pp The +.Fn strerror_r +function renders the same result into +.Fa strerrbuf +for a maximum of +.Fa buflen +characters and returns 0 upon success. +.Pp +The .Fn perror function finds the error message corresponding to the current value of the global variable @@ -94,9 +105,37 @@ otherwise, only the error message string is printed. If .Fa errnum is not a recognized error number, -the error message string will contain +.Fn strerror +returns an error message string containing .Dq Li "Unknown error:\ " -followed by the error number in decimal. +followed by the error number in decimal and sets +.Va errno +to +.Er EINVAL . +.Fn strerror_r +leaves +.Fa strerrbuf +unchanged and returns +.Er EINVAL . +Error numbers recognized by this implementation fall in +the range 0 <= +.Fa errnum +< +.Fa sys_nerr . +.Pp +If insufficient storage is provided in +.Fa strerrbuf +(as specified in +.Fa buflen ) +to contain the error string, +.Fn strerror_r +returns +.Er ERANGE +and +.Fa strerrbuf +will contain an error message that has been truncated and nul +terminated to fit the length specified by +.Fa buflen . .Pp The message strings can be accessed directly using the external array @@ -107,6 +146,8 @@ contains a count of the messages in .Va sys_errlist . The use of these variables is deprecated; .Fn strerror +or +.Fn strerror_r should be used instead. .Sh SEE ALSO .Xr intro 2 , @@ -118,6 +159,13 @@ and .Fn perror functions first appeared in .Bx 4.4 . +The +.Fn strerror_r +function was implemented in +.Fx 4.4 +by +.An Wes Peters +.Aq wes@freebsd.org . .Sh BUGS For unknown error numbers, the .Fn strerror |
