Subj : Re: How to deal with errno in a multipthread program To : comp.programming.threads From : Sean Burke Date : Mon Apr 18 2005 09:38 pm Paul Pluzhnikov writes: > Eric Sosman writes: > > > However, you do not need to worry. The thread > > implementation itself arranges to have a unique `errno' > > for each thread: > > Minor correction: the thread implementation will do so *provided* > you compile your program correctly for MT execution. > > On Solaris, that means adding '-mt' flag if using WorkShop compilers > or '-pthreads' if using gcc. > > On Linux, errno is thread-safe without any flags at all, but > '-pthread' ([1]) is recommended anyway. > > On AIX, -D_THREADS is required (IIRC). > > The OP should read his compiler documentation and/or system headers > to figure out what (if anything) is needed on his platform. > > Cheers, > > [1] Yes, this is not a typo: the Solaris and Linux gcc options > differ: '-pthreads' vs. '-pthread'. There might be a good reason > for this, but I do not know it. If you do, please let me know. It doesn't appear that anyone else mentioned this, so let me add that it is important to #include . Simply doing extern int errno; does not suffice. -SEan .