免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2161 | 回复: 5

注册哑信号处理器的目的? [复制链接]

论坛徽章:
0
发表于 2008-07-25 11:50 |显示全部楼层
static void dummy_signal_handler(int sig)
{
   
}
child_process()
{
        /* remove SIGTERM from the set of blocked signals...  if one of
         * the other threads in the process needs to take us down
         *  it will send us SIGTERM
         */
        unblock_signal(SIGTERM);
        signal(SIGTERM, dummy_signal_handler);
        /* Watch for any messages from the parent over the POD */
        while (1) {
               check_if_exit(pipe)----------------------检测是否有通知到来
               some process;
        }
}
发现很多地方注册哑信号处理器,目的应该是为了即时响应退出,但不是太明白必要性和处理流程,请教!

论坛徽章:
0
发表于 2008-07-25 12:28 |显示全部楼层
顶顶更健康

论坛徽章:
0
发表于 2008-07-25 19:39 |显示全部楼层
原帖由 zhoubug 于 2008-7-25 11:50 发表
static void dummy_signal_handler(int sig)
{
   
}
child_process()
{
        /* remove SIGTERM from the set of blocked signals...  if one of
         * the other threads in the process nee ...



如果不注册的话,一般情况你的程序就退出了
注册了,你的程序就不会退出:)
基本上就是这么简单

论坛徽章:
0
发表于 2008-07-25 21:02 |显示全部楼层
从阻塞中返回,继续执行

论坛徽章:
0
发表于 2010-03-01 19:37 |显示全部楼层
既希望遇到信号不退出,又希望等待可以被信号激活

论坛徽章:
0
发表于 2010-03-02 10:07 |显示全部楼层
要么是预留的,不然直接ignore就好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP