Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106096456
D27623.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
936 B
Referenced Files
None
Subscribers
None
D27623.diff
View Options
Index: head/lib/libc/string/strerror.3
===================================================================
--- head/lib/libc/string/strerror.3
+++ head/lib/libc/string/strerror.3
@@ -32,7 +32,7 @@
.\" @(#)strerror.3 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd December 7, 2020
+.Dd December 17, 2020
.Dt STRERROR 3
.Os
.Sh NAME
@@ -170,6 +170,31 @@
or
.Fn strerror_r
should be used instead.
+.Sh EXAMPLES
+The following example shows how to use
+.Fn perror
+to report an error.
+.Bd -literal -offset 2n
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(void)
+{
+ int fd;
+
+ if ((fd = open("/nonexistent", O_RDONLY)) == -1) {
+ perror("open()");
+ exit(1);
+ }
+ printf("File descriptor: %d\en", fd);
+ return (0);
+}
+.Ed
+.Pp
+When executed, the program will print an error message along the lines of
+.Ql "open(): No such file or directory" .
.Sh SEE ALSO
.Xr intro 2 ,
.Xr err 3 ,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 26, 8:29 AM (11 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15602847
Default Alt Text
D27623.diff (936 B)
Attached To
Mode
D27623: strerror.3: Add an example for perror()
Attached
Detach File
Event Timeline
Log In to Comment