POSIX thread functions and errno
Posted on 2007-08-04
Do POSIX thread functions (e.g. pthread_create, pthread_join, etc) set errno if they fail?
Unlike most standard C functions or system calls, pthread functions return an integer corresponding to an error number, rather than returning -1 to inidcate an error. The man pages for pthread functions conspicuously avoid saying that errno will be set if an error occurs. However, a test program I created seems to indicate that pthread functions actually *do* set errno if there is an error, as well as returning an integer corresponding to the error.
But since the man pages do not explicitly say that pthread functions set errno, and also since there is another mechanism in place to report errors for pthread functions, I suspect that I shouldn't rely on pthread functions setting errno when it comes to portability. Perhaps this is not standard.
Does anyone know?