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

Signal Handling--ref

发布时间:2021-01-25 23:15:02 所属栏目: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
副标题[/!--empirenews.page--]

    A program error such as dividing by zero or issuing an address outside the valid range.
  • A user request to interrupt or terminate the program. Most environments are set up to let a user suspend the program by typingC-z,or terminate it withC-c. Whatever key sequence is used,the operating system sends the proper signal to interrupt the process.
  • The termination of a child process.
  • Expiration of a timer or alarm.
  • A call tokillorraiseby the same process.
  • A call tokillfrom another process. Signals are a limited but useful form of interprocess communication.
  • An attempt to perform an I/O operation that cannot be done. Examples are reading from a pipe that has no writer (see section),and reading or writing to a terminal in certain situations (see section).

killandraise) generates its own particular kind of signal. The various kinds of signals are listed and described in detail in section.

openreturns-1. In general,errors that are necessarily associated with certain library functions are reported by returning a value that indicates an error. The errors which raise signals are those which can happen anywhere in the program,not just in library calls. These include division by zero and invalid memory addresses.

killwhose purpose is specifically to generate a signal.

SIGKILLandSIGSTOP,the action is fixed,but for most signals,the program has a choice: ignore the signal,specify ahandler function,or accept thedefault actionfor that kind of signal. The program specifies its choice using functions such assignalorsigaction(see section). We sometimes say that a handlercatchesthe signal. While the handler is running,that particular signal is normally blocked.

waitorwaitpidfunctions. (This is discussed in more detail in section.) The information it can get includes the fact that termination was due to a signal,and the kind of signal involved. If a program you run from a shell is terminated by a signal,the shell typically prints some kind of error message.

`signal.h'.

intNSIG
The value of this symbolic constant is the total number of signals defined. Since the signal numbers are allocated consecutively,NSIGis also one greater than the largest defined signal number.

longjmpto return control to the command level.

raiseorkillinstead of a real error.

`core'and is written in whichever directory is current in the process at the time. (On the GNU system,you can specify the file name for core dumps with the environment variableCOREFILE.) The purpose of core dump files is so that you can examine them with a debugger to investigate what caused the error.

intSIGFPE
TheSIGFPEsignal reports a fatal arithmetic error. Although the name is derived from "floating-point exception",this signal actually covers all arithmetic errors,including division by zero and overflow. If a program stores integer data in a location which is then used in a floating-point operation,this often causes an "invalid operation" exception,because the processor cannot recognize the data as a floating-point number.

(编辑:威海站长网)

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

热点阅读