Fix pthread error reporting: pthread functions don't set errno but just return the error number.
This ensures errno is one would expect and this way error handling can be uniform everywhere.