summaryrefslogtreecommitdiff
path: root/libc/error/perror.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/error/perror.c')
-rw-r--r--libc/error/perror.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libc/error/perror.c b/libc/error/perror.c
new file mode 100644
index 0000000..f9b0965
--- /dev/null
+++ b/libc/error/perror.c
@@ -0,0 +1,19 @@
+
+#include <errno.h>
+
+void
+perror(str)
+__const char * str;
+{
+ register char * ptr;
+ if(str)
+ {
+ write(2, str, strlen(str));
+ write(2, ": ", 2);
+ }
+ else write(2, "perror: ", 8);
+
+ ptr = strerror(errno);
+ write(2, ptr, strlen(ptr));
+ write(2, "\n", 1);
+}