musl/src/stdio/perror.c

23 lines
343 B
C
Raw Normal View History

2011-02-12 00:22:29 -05:00
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "stdio_impl.h"
void perror(const char *msg)
{
FILE *f = stderr;
char *errstr = strerror(errno);
FLOCK(f);
2012-06-20 09:27:28 -04:00
if (msg && *msg) {
fwrite(msg, strlen(msg), 1, f);
fputc(':', f);
fputc(' ', f);
2011-02-12 00:22:29 -05:00
}
fwrite(errstr, strlen(errstr), 1, f);
fputc('\n', f);
2011-02-12 00:22:29 -05:00
FUNLOCK(f);
}