加入收藏 | 设为首页 | 会员中心 | 我要投稿 威海站长网 (https://www.0631zz.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Signal Handling--ref

发布时间:2021-01-25 08:01:09 所属栏目:Linux 来源:网络整理
导读:signal is a software interrupt delivered to a process. The operating system uses signals to report exceptional situations to an executing program. Some signals report errors such as references to invalid memory addresses; others report asy

The namesighandler_tfor this data type is a GNU extension.

sighandler_tsignal(intsignum,sighandler_taction)
Thesignalfunction establishesactionas the action for the signalsignum.

The first argument,signum,identifies the signal whose behavior you want to control,and should be a signal number. The proper way to specify a signal number is with one of the symbolic signal names described in section---don't use an explicit number,because the numerical code for a given kind of signal may vary from operating system to operating system.

The second argument,action,specifies the action to use for the signalsignum. This can be one of the following:

SIG_DFL
SIG_DFLspecifies the default action for the particular signal. The default actions for various kinds of signals are stated in section.
SIG_IGN
SIG_IGNspecifies that the signal should be ignored. Your program generally should not ignore signals that represent serious events or that are normally used to request termination. You cannot ignore theSIGKILLorSIGSTOPsignals at all. You can ignore program error signals likeSIGSEGV,but ignoring the error won't enable the program to continue executing meaningfully. Ignoring user requests such asSIGINT,SIGQUIT,andSIGTSTPis unfriendly. When you do not wish signals to be delivered during a certain part of the program,the thing to do is to block them,not ignore them. See section.
handler
Supply the address of a handler function in your program,to specify running this handler as the way to deliver the signal. For more information about defining signal handler functions,see section.

If you set the action for a signal toSIG_IGN,or if you set it toSIG_DFLand the default action is to ignore that signal,then any pending signals of that type are discarded (even if they are blocked). Discarding the pending signals means that they will never be delivered,not even if you subsequently specify another action and unblock this kind of signal.

(编辑:威海站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读