blob: 4349ac5e6fc1c75704a7f6bdd2560607fa165af7 [file] [log] [blame]
Rich Felker0b44a032011-02-12 00:22:29 -05001#include <stdio.h>
2#include <string.h>
3#include <errno.h>
4#include "stdio_impl.h"
5
6void perror(const char *msg)
7{
Rich Felker0b44a032011-02-12 00:22:29 -05008 FILE *f = stderr;
9 char *errstr = strerror(errno);
10
11 FLOCK(f);
12
13 if (msg) {
Rich Felker7683fce2011-07-30 06:11:16 -040014 fwrite(msg, strlen(msg), 1, f);
15 fputc(':', f);
16 fputc(' ', f);
Rich Felker0b44a032011-02-12 00:22:29 -050017 }
Rich Felker7683fce2011-07-30 06:11:16 -040018 fwrite(errstr, strlen(errstr), 1, f);
19 fputc('\n', f);
Rich Felker0b44a032011-02-12 00:22:29 -050020
21 FUNLOCK(f);
Rich Felker0b44a032011-02-12 00:22:29 -050022}