读书人

pthread_join回来非0但 perror 提示

发布时间: 2013-01-23 10:44:49 作者: rapoo

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

读书人网 >UNIXLINUX

热点推荐