- 论坛徽章:
- 5
|
回复 10# myworkstation
额,也不全是,那个cond wait的似乎没问题了,现在就是没有cond wait的死循环线程有问题,我在那个线程里面调用了pipe去读取外部命令,然后主线程关闭这个线程的时候会时不时的打印出:
Original exception was:
close failed in file object destructor:
Error in sys.excepthook:
这种错误,也就是说在pipe打开的时候线程响应了pthread_cancel的消息?
我刚刚在打开pipe之前加了
pthread_testcancel();
pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
然后再关闭pipe之后加上
pthread_setcancelstate(PTHREAD_CANCEL_ENABLe, NULL);
也没解决这个问题。。按照手册上不是说,如果吧cancelstate改成disable了,就不会响应pthread_cancel的讯号了吗? |
|