这个问题是由于访问内存错误造成的,例如一次时因为循环越界,导致访问界外内存时出现过此种问题。
2、程序卡死的问题,就是程序的进程还在,但是却卡在那里什么都不做,该问题可能也是内存访问越界造成的;
另外还可能是多线程中混合使用C和C++的函数造成,例如:某些嵌入式linux平台对C++支持的不好,这时候如果在多线程中混合使用printf和cout,就会造成此问题。
unzip xx.zip >/dev/null 2>&1一楼的回答也对,但用的时候一般不用加最前面的1
unzip xx.zip >/dev/null
前半部分是将标准输出重定向到空设备,
后面的2>&1就将标准错误输出重定向到标准输出,这样最终也是到空设备。
pthread_join 线程停止等待函数没有调用pthread_create 线程生成后,没有等子线程停止,主线程就先停止了。
主线程停止后,整个程序停止,子线程在没有printf的时候就被结束了。
结论:不是你没有看到结果,而是在子线程printf("..................\n")之前整个程序就已经停止了。
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#define FALSE -1
#define TRUE 0
void *shuchu( void *dumy )
{
int j
printf("..................\n")
}
int main()
{
int i = 0
int rc = 0
int ret1
pthread_t p_thread1
if(0!=(ret1 = pthread_create(&p_thread1, NULL, shuchu, NULL)))printf("sfdfsdfi\n")
printf("[%d]\n",p_thread1)
pthread_join(p_thread1, NULL)
return TRUE
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)