You might have not saved errno.
----------------------------------------------
// WRONG way
create_thread()
{
pthread_create(...);
printf("im in thread");
}
main()
{
create_thread();
// printf at create_thread() has changed errno
// u'll get success
printf("%s", strerror(errno));
}
----------------------------------------------
so you better do something like
----------------------------------------------
// CORRECT way
create_thread()
{
pthread_create(...);
int my_errno = errno;
printf("im in thread");
return my_errno;
}
main()
{
int my_errno = create_thread();
// OK
printf("%s", strerror(my_errno));
}
----------------------------------------------
--- In [email protected], "John Gunnarsson"
<[EMAIL PROTECTED]> wrote:
>
> Sorry guys to bother you with this, it was a typo by me:
>
> errno -> errorno
>
> //John
>
>
> On 7/28/07, John Gunnarsson <[EMAIL PROTECTED]> wrote:
> > I've written a wrapper for confitions (pthread_cond_*) and sometimes
> > (not all the times) I get a strange returnvalue from
> > pthread_cond_timedwait().
> >
> > the numeric returnvalue is 22 (which should be an error, since
> > everyting but 0 is failure, ETIMEOUT counted), 22 seems to be EINVAL,
> > which is a legitimate error.
> >
> > The really strange thing is when i use the function strerror_r() to
> > translate the errornumber into a string (which i use to throw an
> > exception), the string simply contains "Success" !!????
> >
> > Can't I use strerror_r() on returnvalues from pthread_cond_timedwait()
> > function and similar?
> >
> > Is strerror_r() function only to be used for errorvalues stored in the
> > errno.h's errno variable?
> >
> > //John
> >
>