【发布时间】:2012-09-17 08:47:07
【问题描述】:
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
char a[]="Hello";
void * thread_body(void * param) {
while(1)
printf("%s\n", param);
}
int main(int argc, char *argv[]) {
pthread_t threadHello;
int code;
pthread_create(&threadHello, NULL, thread_body, a);
pthread_cancel(threadHello);
pthread_exit(0);
}
当我在 Solaris 10 (SunOS 5.10) 下编译和运行它时,它不会停止。但在 Linux 下它可以正常工作。
【问题讨论】:
-
pthread_cancel()返回什么值? -
你有没有read the manual检查过目标线程的取消状态和类型?
-
@kerrek-sb 是的,我阅读了 linux 和 solaris 下的手册页。
-
@KingsIndian 没有任何改变
-
@AlexeyMatveev 你检查过这些函数的返回值了吗?他们都成功了?