Signal Handling–ref

http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_21.htmlAsignalis a software interrupt deli

    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.

作者: dawei

【声明】:永州站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部