I'd like to know, how to make errno global variable thread-safe ( the one , system calls return error codes through) . Suppose, I have two threads, and both of them call write(). It fails on both either, but for one errno is EINVAL and for the second ENODEV. I guess that if this happens more or less in the same time, I would get only the last error code.
Does anyone have any idea how to make this errno thread safe, and what might be a workaround ?