summaryrefslogblamecommitdiff
path: root/src/stdio/perror.c
blob: 4349ac5e6fc1c75704a7f6bdd2560607fa165af7 (plain) (tree)
1
2
3
4
5
6
7






                            





                                       


                                               
         

                                             

                   
 
#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);
	
	if (msg) {
		fwrite(msg, strlen(msg), 1, f);
		fputc(':', f);
		fputc(' ', f);
	}
	fwrite(errstr, strlen(errstr), 1, f);
	fputc('\n', f);

	FUNLOCK(f);
}