GDB调试线程,退出时老是出现异常
代码如下:
//多线程编程测试
#include <stdio.h>
#include<pthread.h>
//线程执行函数
void thread(void)
{
int i;
for( i = 0;i < 5; i++ ){
printf("This is a pthread.\n");
//sleep(2);
}
} //GDB调试到这里退出线程就会出现异常
int main(void)
{
pthread_t id;
int i,ret;
ret = pthread_create(&id,NULL,(void *)thread, NULL);
if ( ret!=0 ) { //不为0说明线程创建失败
printf ("Create pthread error!\n");
exit (1);
}
pthread_join(id,NULL);
return (0);
}
推出线程函数就会异常,异常表现如下:
0x009c33ae in start_thread () from /lib/tls/libpthread.so.0
(gdb)
Single stepping until exit from function start_thread,
which has no line number information.
[Thread -1208013904 (LWP 3165) exited]
然后就无法退出调试状态,CTRL+C都不管用....
也不知道是那出问题了.