日期:2014-05-16  浏览次数:21023 次

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));
}