sigaction:恢复处理程序与否? [英] sigaction: restore handler or not?

查看:32
本文介绍了sigaction:恢复处理程序与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在代码的开头调用 sigaction,

if i call sigaction at the beginning of my code,

sigaction(SIGPIPE, &pipe_act, NULL);

如果我收到 sigpipe,在执行 pipe_act 后,安装的处理程序仍然是 pipe_Act,还是自动为 sigpipe 设置了默认处理程序?

if i receive sigpipe, after the execution of pipe_act the handler installed remains pipe_Act, or the default handler is automatically set for sigpipe?

推荐答案

这取决于您的标志 (pipe_act->sa_flags) 是否包含 SA_RESETHAND.如果是,则信号处理程序是一次性"并在被调用后被删除(即处理程序被重置为默认处理程序),但如果不是,则处理程序保持原位,直到您手动更改它.

It depends on whether or not your flags (pipe_act->sa_flags) include SA_RESETHAND. If yes, then the signal handler is a "one-shot" and gets removed after having been called (i.e. the handler is reset to the default handler), but if not, then the handler remains in place until you change it manually.

这篇关于sigaction:恢复处理程序与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆