Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/string/strerror.3
Show All 26 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)strerror.3 8.1 (Berkeley) 6/9/93 | .\" @(#)strerror.3 8.1 (Berkeley) 6/9/93 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd April 5, 2011 | .Dd December 7, 2020 | ||||
.Dt STRERROR 3 | .Dt STRERROR 3 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm perror , | .Nm perror , | ||||
.Nm strerror , | .Nm strerror , | ||||
.Nm strerror_l , | |||||
.Nm strerror_r , | .Nm strerror_r , | ||||
.Nm sys_errlist , | .Nm sys_errlist , | ||||
.Nm sys_nerr | .Nm sys_nerr | ||||
.Nd system error messages | .Nd system error messages | ||||
.Sh LIBRARY | .Sh LIBRARY | ||||
.Lb libc | .Lb libc | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.In stdio.h | .In stdio.h | ||||
.Ft void | .Ft void | ||||
.Fn perror "const char *string" | .Fn perror "const char *string" | ||||
.Vt extern const char * const sys_errlist[] ; | .Vt extern const char * const sys_errlist[] ; | ||||
.Vt extern const int sys_nerr ; | .Vt extern const int sys_nerr ; | ||||
.In string.h | .In string.h | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn strerror "int errnum" | .Fn strerror "int errnum" | ||||
.Ft "char *" | |||||
.Fn strerror_l "int errnum" "locale_t" | |||||
.Ft int | .Ft int | ||||
.Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen" | .Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen" | ||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
The | The | ||||
.Fn strerror , | .Fn strerror , | ||||
.Fn strerror_r | .Fn strerror_l , | ||||
.Fn strerror_r , | |||||
and | and | ||||
.Fn perror | .Fn perror | ||||
functions look up the error message string corresponding to an | functions look up the error message string corresponding to an | ||||
error number. | error number. | ||||
.Pp | .Pp | ||||
The | The | ||||
.Fn strerror | .Fn strerror | ||||
function accepts an error number argument | function accepts an error number argument | ||||
.Fa errnum | .Fa errnum | ||||
and returns a pointer to the corresponding | and returns a pointer to the corresponding message string in the current locale. | ||||
message string. | The function is not thread-safe, it returns pointer to the buffer the could | ||||
emaste: Maybe:
```
.Fn strerror
is not thread-safe.
It returns a pointer to an internal buffer that… | |||||
be overwritten by a call to | |||||
.Fn strerror | |||||
from other thread. | |||||
.Pp | |||||
The | |||||
.Fn strerror_l | |||||
takes an error number and locale arguments and return string, | |||||
emasteUnsubmitted Done Inline ActionsMaybe The .Fn strerror_l function accepts error number and locale arguments and returns a pointer to a string corresponding to the specified error in the given locale. .Fn strerror-l is thread-safe. emaste: Maybe
```
The
.Fn strerror_l
function accepts error number and locale arguments and returns a… | |||||
corresponding to specified error, in the requested locale. | |||||
The function is thread-safe. | |||||
.Pp | .Pp | ||||
The | The | ||||
.Fn strerror_r | .Fn strerror_r | ||||
function renders the same result into | function renders the same result into | ||||
.Fa strerrbuf | .Fa strerrbuf | ||||
for a maximum of | for a maximum of | ||||
.Fa buflen | .Fa buflen | ||||
characters and returns 0 upon success. | characters and returns 0 upon success. | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
.Va sys_errlist . | .Va sys_errlist . | ||||
The external value | The external value | ||||
.Va sys_nerr | .Va sys_nerr | ||||
contains a count of the messages in | contains a count of the messages in | ||||
.Va sys_errlist . | .Va sys_errlist . | ||||
The use of these variables is deprecated; | The use of these variables is deprecated; | ||||
.Fn strerror | .Fn strerror | ||||
or | or | ||||
.Fn strerror_r | .Fn strerror_r | ||||
jillesUnsubmitted Done Inline ActionsAdd .Fn strerror_l here as well? jilles: Add `.Fn strerror_l` here as well? | |||||
should be used instead. | should be used instead. | ||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr intro 2 , | .Xr intro 2 , | ||||
.Xr err 3 , | .Xr err 3 , | ||||
.Xr psignal 3 | .Xr psignal 3 | ||||
.Sh STANDARDS | .Sh STANDARDS | ||||
The | The | ||||
.Fn perror | .Fn perror | ||||
Show All 36 Lines |
Maybe:
(.Nm or .Fn as appropriate)