In errno.h
, this variable is declared as extern int errno;
so my question is, is it safe to check errno
value after some calls or use perror() in multi-threaded code. Is this a thread safe variable? If not, then whats the alternative ?
I am using linux with gcc on x86 architecture.
Best Answer
Yes, it is thread safe. On Linux, the global errno variable is thread-specific. POSIX requires that errno be threadsafe.
See http://www.unix.org/whitepapers/reentrant.html
Also see http://linux.die.net/man/3/errno