Getting errno in a Multithreaded program

In Tru64 Unix, the 'errno' variable is not thread safe.
Could anybody help me about how to make it thread safe or how to check 'errno' in a Multithreaded program ????

The Programming process is like this.

There are some definite number of threads having their own task.
There is one particular thread which tries to read from Disk.
We know that there can be n-number of possibilities for a read to fail. So, depeinding upon the error number thrown from a read failure., I call appropriate thread to take some action .

This task works fine when implemented as a Monolithic Program (i.e., non-multi threaded approach) but since my program is a multithreaded I'm not able to get the appropriate error no. as it is not thread safe.

So, can any body help me out with some technic/method of getting/traping out the appropriate errno.

Thanks in advance.

Each thread gets it's own copy of the global variable: errno. This is done automatically by the Threads Library. So, have fun!!! :smiley:

Rgds
SHAIK

Sorry for the Delayed Update.

In case of Multi Threaded Programming., just before including the
pthread.h file just define _REENTRANT., then the system will take care of making the errno thread safe.

Ex:-

#define _REENTRANT

#include <pthread.h>

main()
{
}

Regards