pthread_testcancel函数用法详解
pthread_testcancel函数简介
- 头文件包含
#include <pthread.h>
- 函数定义
void pthread_testcancel(void);
- 编译链接选项
-pthread
pthread_testcancel函数常见使用错误
- 链接错误
undefined reference to `pthread_testcancel'
解决办法:添加链接选项
-pthread
- 编译错误
warning: implicit declaration of function ‘pthread_testcancel’ [-Wimplicit-function-declaration]
解决办法:包含头文件
#include <pthread.h>
pthread_testcancel函数详细描述
调用pthread_testcancel ()在调用线程中创建一个取消点,以便执行不包含取消点的代码的线程将响应取消请求。
如果禁用可取消性(使用pthread_setcancelstate (3))或没有取消请求挂起,则调用pthread_testcancel ()无效。
pthread_testcancel函数返回值
此函数不返回值。如果调用此函数的结果是取消了调用线程,则该函数不会返回。
pthread_testcancel函数错误码
这个函数总是成功的。
pthread_testcancel函数使用举例
参见pthread_cleanup_push (3)
评论区