各位,请教下,我的设备后台运行的进程无法产生core文件,但是前端运行产生了文件。实在搞不懂。大家支支招。在/etc/profile有加入以下三行
ulimit -c unlimited
echo "1" > /proc/sys/kernel/core_uses_pid
echo "/data/app/core-%e-%p-%t" > /proc/sys/kernel/core_pattern但仍旧是,后台运行,程序崩溃后不产生core,前端运行,程序崩溃后产生core;
何解?

解决方案 »

  1.   

    解决了,要想让后台程序生成core,除了要满足以上的设置,还必须在应用源码里面加上以下代码:    int iRes = RLIMIT_CORE;
        struct rlimit stRlim;
        /* 允许生成core文件 */
        stRlim.rlim_cur = stRlim.rlim_max = RLIM_INFINITY;
        if (0 != setrlimit(iRes, &stRlim))
        {
         printf("Error: setrlimit failed, %s\n", strerror(errno));
            return APP_RET_ERROR;
        }本人如此修改亲测可行,有更好方法的也可以留言。
      

  2.   

    学到了,还真没研究过后台程序生成core的方法
      

  3.   

    请问让后台生成core的代码是加在main文件里面吗?还是放在其他地方,新手求解答