设为首页 加入收藏

TOP

Linux生成Core_file机制
2014-11-24 14:12:40 来源: 作者: 【 】 浏览:1
Tags:Linux 生成 Core_file 机制

#include


// 产生core文件函数
int SetRLimit()
{
#ifdef WIN32
#else
struct rlimt tRLimit;
int iRtn = 0;
printf("SetRLimit ...\n");
iRtn = getrlimit(RLIMIT_CORE, &tRLimt);
if(0 == iRtn)
{
printf("getrlimit corefile size limit_cur = %d, max = %d\n", tRLimit.rlimit.rlim_cur, tRLimit.rlim_max);
tRLimit.rlim_max = tRLimit.rlim_cur = RLIM_INFINITY;
iRtn = setrlimit(RLIMIT_CORE, &tRLimit);
printf("setrlimit corefile size limit:cur = %d, return %d\n", tRLimit.rlim_cur, iRtn);
}
iRtn = getrlimit(RLIMIT_NOFILE, &tRLimit);
if(0 == iRtn)
{
printf("getrlimit number of files limit : cur = %d, max = %d\n", tRLimit.rlim_cur, tRLimit.rlim_max);
tRLimit.rlim_cur = 10000;
iRtn = setrlimit(RLIMIT_NOFILE, &tRLimit);
printf("setrlimit number of files limit : cur = %d, return %d\n",tRLimit.rlim_cur, iRtn);
}
#endif
return 0;
}


int mian()
{
unsigned char *ptr = 0x00;
SetRLimit();
*ptr =0x00; //会产生段错误,测试生产core文件
return 0;
}


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C语言 字符指针和字符数组的区别 下一篇如何使用LCC编译C文件到MIPS 汇编

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: