- 论坛徽章:
- 0
|
#include "unp.h"
static int x = 3;
void *func(void *arg);
int main(void)
{
pthread_t tid;
int error;
void *retval;
if ((error = pthread_create(&tid, NULL, func, NULL)) != 0)
errno = error, err_sys("pthread_create");
if ((error = pthread_join(tid, &retval)) != 0)
errno = error, err_sys("pthread_join");
printf("return value = %d\n", *((int*)retval));
exit(0);
}
void *func(void *arg)
{
pthread_exit(&x);
}
void err_sys(const char *errmsg)
{
perror(errmsg);
exit(1);
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/39758/showart_344289.html |
|