pthread_setcancelstate() returns zero after completing successfully. Any other returned value indicates that an error occurred. When the following condition occurs, the pthread_setcancelstate() function fails and returns the corresponding value.
EINVAL
The state is not PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.