libc: make perror output to stderr

This commit is contained in:
apio 2022-10-11 21:13:38 +02:00
parent b67011c626
commit 88a01fcfc7

View File

@ -15,11 +15,11 @@ extern "C"
nwritten += fwrite("\n", 1, 1, stdout); nwritten += fwrite("\n", 1, 1, stdout);
return (int)nwritten; return (int)nwritten;
} }
void perror(const char* s) // FIXME: Print to stderr, whenever we have an stderr. void perror(const char* s)
{ {
int savederr = int savederr =
errno; // This was necessary before, but even more now since we clear errno on successful syscalls now. errno; // This was necessary before, but even more now since we clear errno on successful syscalls now.
if (s && *s) { printf("%s: ", s); } if (s && *s) { fprintf(stderr, "%s: ", s); }
printf("%s\n", strerror(savederr)); fprintf(stderr, "%s\n", strerror(savederr));
} }
} }