Subj : Re: How to deal with errno in a multipthread program To : comp.programming.threads From : icoming Date : Sat Apr 16 2005 04:51 am >> Is it enough to deal with it as follow: >> int err=errno; >> func(); //this function may modify the errno >> errno=err; >> I read W.Richard Stevens's UNIX Network Programming, it uses this way, >> but I do not think it's enough, but do not know there is better one. > What is the problem you are trying to solve? > DS I thought errno is a global variable, and worried that in a multithread program the functions which will change the value of errno can not work well. For example, Func1() which will change errno is called by Thread A, a schedule happens, Thread B runs, and called Func2() which will also change errno. Now Thread A is scheduled to run again, but the errno has changed by Func2(). But Eric Sosman said that every thread has its own errno, and asked me not to worry about it. .