errno is per thread (stored in TLS).