设为首页 加入收藏

TOP

C++程序作为Linux服务启动时出core的位置
2014-11-24 02:33:50 来源: 作者: 【 】 浏览:0
Tags:程序 作为 Linux 服务 启动 时出 core 位置

C++程序作为Linux服务启动时出core的位置


首先,要确保生成core,需要运行命令


ulimit -c unlimited


这个在脚本中设置还是很简单的,比如在/etc/init.d/data_service脚本中:


PROGRAM=/home/dist/tcp/data_service_d



test -x $PROGRAM || exit 0


case "$1" in
start)
log_begin_msg "Starting data service"
ulimit -c unlimited
$PROGRAM /home/dist/tcp/config.xml &
cd -
log_end_msg 0
;;
stop)
PID=`pidof data_service_d`
log_begin_msg "Stopping data service"
if [ ! -z "$PID" ]; then
kill -15 $PID
fi
log_end_msg 0
;;
restart)
$0 stop
$0 start
;;
*)
log_success_msg "Usage: service data_service {start|stop|restart}"
exit 1
esac


exit 0


但是很快就发现,core文件的位置不在/home/dist/tcp目录下,而是在/ 目录下。


这是通过pidof data_service_d 找到进程id,然后查到cwd链接指向的是/


ot@vm6:/# pidof data_service_d
12326
root@vm6:/# ls /proc/12326/cwd -alh
lrwxrwxrwx 1 root root 0 Sep 24 11:41 /proc/12326/cwd -> /


相关阅读


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇jQuery基础及选择器 下一篇使用Linux静态库

评论

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