plan9fox/sys/src/ape/lib/ap/stdio/perror.c
cinap_lenrek 25f04a68a1 ape: threadsafe errno
store errno on the private process stack so its always per process
and not just per memory space. errno itself becomes a macro
dereferencing int *_errnoloc; which is initialized from main9.s
pointing to the private stack location.

various fixes in programs that just imported errno variable with
"extern int errno;" instead of including <errno.h>.
2013-03-11 18:57:22 +01:00

13 lines
237 B
C

/*
* pANS stdio -- perror
*/
#include "iolib.h"
#include <errno.h>
void perror(const char *s){
if(s!=NULL && *s != '\0') fputs(s, stderr), fputs(": ", stderr);
fputs(strerror(errno), stderr);
putc('\n', stderr);
fflush(stderr);
}