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 15, 2020 | ||||||||||||
.Dt STRERROR 3 | .Dt STRERROR 3 | ||||||||||||
.Os | .Os | ||||||||||||
.Sh NAME | .Sh NAME | ||||||||||||
.Nm perror , | .Nm perror , | ||||||||||||
.Nm strerror , | .Nm strerror , | ||||||||||||
.Nm strerror_r , | .Nm strerror_r , | ||||||||||||
.Nm sys_errlist , | .Nm sys_errlist , | ||||||||||||
.Nm sys_nerr | .Nm sys_nerr | ||||||||||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | |||||||||||||
.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 | ||||||||||||
should be used instead. | should be used instead. | ||||||||||||
.Sh EXAMPLES | |||||||||||||
The following example shows how to use | |||||||||||||
.Fn perror | |||||||||||||
to report an error. | |||||||||||||
.Bd -literal -offset 2n | |||||||||||||
#include <stdio.h> | |||||||||||||
#include <stdlib.h> | |||||||||||||
#include <unistd.h> | |||||||||||||
int | |||||||||||||
main(void) | |||||||||||||
yuripvUnsubmitted Done Inline Actions
yuripv: | |||||||||||||
{ | |||||||||||||
if (pipe(NULL) < 0) { | |||||||||||||
jillesUnsubmitted Not Done Inline ActionsThis is not a great example since it is undefined behaviour. In fact, before FreeBSD 11.0, this caused a segmentation fault instead of an error return. Perhaps a better example is fd = open("/dev/null/wrong", O_RDONLY); which will fail with Not a directory. jilles: This is not a great example since it is undefined behaviour. In fact, before FreeBSD 11.0, this… | |||||||||||||
0mpAuthorUnsubmitted Done Inline ActionsHa, fascinating! Thanks a lot, I'll update the revision shortly. 0mp: Ha, fascinating! Thanks a lot, I'll update the revision shortly. | |||||||||||||
perror("pipe()"); | |||||||||||||
exit(1); | |||||||||||||
} | |||||||||||||
return (0); | |||||||||||||
} | |||||||||||||
.Ed | |||||||||||||
.Pp | |||||||||||||
When executed, the program will print an error message along the lines of | |||||||||||||
.Ql pipe(): Bad address . | |||||||||||||
.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 | ||||||||||||
and | and | ||||||||||||
Show All 35 Lines |