I now see, that at some point pthread_cancel() gets called on this thread and (almost) always returns a nonzero value. Checking errno results in EINPROGRESS.
The pthread*
family of functions does not set errno
, but instead returns the error code as function value.
So do not only test the outcome of the call to pthread_cancel()
against 0
, but actually interpret the value returned as what you "normaly" find in errno
, that is one of the E*
error values.
int result = pthread_cancel(<some-pthread>);
if (0 != result)
{
fprintf(stderr, "pthread_cancel() failed with error #%d: '%s'\n", result, strerror(result)); /* Better use strerror_r() in a multithreaded enviroment. */
}
Btw: Inspecting the sources of the libc you seem to be using does not reveal any hints of pthread_cancel()
returning EINPROGRESS
.