perror.c 294 B

12345678910111213141516171819
  1. #include <unistd.h>
  2. #include <string.h>
  3. #include <errno.h>
  4. void perror(str)
  5. __const char *str;
  6. {
  7. register char *ptr;
  8. if (str) {
  9. write(2, str, strlen(str));
  10. write(2, ": ", 2);
  11. } else
  12. write(2, "perror: ", 8);
  13. ptr = strerror(errno);
  14. write(2, ptr, strlen(ptr));
  15. write(2, "\n", 1);
  16. }