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

Signal Handling--ref

发布时间:2021-01-24 20:17:15 所属栏目: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 return value is0on success and-1on failure. Ifsigaltstackfails,it setserrnoto one of these values:

EINVAL
You tried to disable a stack that was in fact currently in use.
ENOMEM
The size of the alternate stack was too small. It must be greater thanMINSIGSTKSZ.

sigstackinterface. You should usesigaltstackinstead on systems that have it.

struct sigstack
This structure describes a signal stack. It contains the following members:
void *ss_sp
This is the stack pointer. If the stack grows downwards on your machine,this should point to the top of the area you allocated. If the stack grows upwards,it should point to the bottom.
int ss_onstack
This field is true if the process is currently using this stack.
intsigstack(const struct sigstack *stack,struct sigstack *oldstack)
Thesigstackfunction specifies an alternate stack for use during signal handling. When a signal is received by the process and its action indicates that the signal stack is used,then this is installed as the new stack for use by signal handlers.

The return value is0on success and-1on failure.

    BSD Unix represents signal masks as anintbit mask,rather than as asigset_tobject.
  • The BSD facilities use a different default for whether an interrupted primitive should fail or resume. The POSIX facilities make system calls fail unless you specify that they should resume. With the BSD facility,the default is to make system calls resume unless you say they should fail. See section.

`signal.h'.

struct sigvec
This data type is the BSD equivalent ofstruct sigaction(see section); it is used to specify signal actions to thesigvecfunction. It contains the following members:
sighandler_t sv_handler
This is the handler function.
int sv_mask
This is the mask of additional signals to be blocked while the handler function is being called.
int sv_flags
This is a bit mask used to specify various flags which affect the behavior of the signal. You can also refer to this field assv_onstack.

sv_flagsfield of asigvecstructure. This field is a bit mask value,so you bitwise-OR the flags of interest to you together.

intSV_ONSTACK
If this bit is set in thesv_flagsfield of asigvecstructure,it means to use the signal stack when delivering the signal.
intSV_INTERRUPT
If this bit is set in thesv_flagsfield of asigvecstructure,it means that system calls interrupted by this kind of signal should not be restarted if the handler returns; instead,the system calls should return with aEINTRerror status. See section.
intSV_RESETHAND
If this bit is set in thesv_flagsfield of asigvecstructure,it means to reset the action for the signal back toSIG_DFLwhen the signal is received.
intsigvec(intsignum,const struct sigvec *action,struct sigvec *old-action)
This function is the equivalent ofsigaction(see section); it installs the actionactionfor the signalsignum,returning information about the previous action in effect for that signal inold-action.
intsiginterrupt(intsignum,intfailflag)
This function specifies which approach to use when certain primitives are interrupted by handling signalsignum. Iffailflagis false,signalsignumrestarts primitives. Iffailflagis true,handlingsignumcauses these primitives to fail with error codeEINTR. See section.

intsigmask(intsignum)
This macro returns a signal mask that has the bit for signalsignumset. You can bitwise-OR the results of several calls tosigmasktogether to specify more than one signal. For example,
(sigmask (SIGTSTP) | sigmask (SIGSTOP)
 | sigmask (SIGTTIN) | sigmask (SIGTTOU))

(编辑:青岛站长网)

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

热点阅读