参考http://blog.csdn.net/lostaway/article/details/40948841 配置,项目有多个module 组成,一部分有gcda 生成,一部分没有,原因是这部分module 在循环处理,永远不退出,
使用 kill -9 关闭,如果程序没有sigaction 函数是无法生成gcda文件的
解决办法,
在main.c 中的main中加入reg_sigterm_handler(sigterm_handler);即可
static void sigterm_handler(int signum)
{
exit(0)
}
void reg_sigterm_handler(void (*handler)(int s))
{
struct sigaction action, old_action;
action.sa_handler = handler;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
sigaction(SIGTERM, NULL, &old_action);
if (old_action.sa_handler != SIG_IGN) {
sigaction(SIGTERM, &action, NULL);
}
}