首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

pthread_join回来非0,但 perror 提示success

2013-01-23 
pthread_join返回非0,但 perror 提示success如题,我的程序中,在主线程中使用pthread_join等待子线程结束。

pthread_join返回非0,但 perror 提示success
如题,


我的程序中,在主线程中使用pthread_join等待子线程结束。
但在长期运行中,偶尔会出现pthread_join返回非0的值,但此时perror返回的是success!

求大侠赐教
[解决办法]
 RETURN VALUE

    If successful, the pthread_join() function returns zero. Otherwise, an error number is returned to indicate the error. 


if ((e = pthread_join(...)) != 0) {
    fprintf(stderr, "pthread_join: %s", strerrno(e));
}


[解决办法]
pthread_join不会设置errno, 而是用返回值指示错误.

if ((e = pthread_join(...)) != 0) {
    fprintf(stderr, "pthread_join: %s", strerror(e));
}

热点排行