Signal.h

Signal.h

signal.h is a header file defined in the C Standard Library to specify how a program handles signals while it executes. A signal can report some exceptional behavior within the program ("such as division by zero"), or a signal can report some asynchronous event outside the program ("such as someone striking an interactive attention key on a keyboard").

A signal can be generated by calling raise (to send a signal to the current process) or kill (to send a signal to any process). Each implementation defines what signals it generates (if any) and under what circumstances it generates them. An implementation can define signals other than the ones listed here. The standard header can define additional macros with names beginning with SIG to specify the values of additional signals. All such values are integer constant expressions >= 0.

You can specify a signal handler for all but two signals (SIGKILL and SIGSTOP cannot be caught, blocked or ignored). A signal handler is a function that the target environment calls when the corresponding signal occurs. The target environment suspends execution of the program until the signal handler returns or calls longjmp. For maximum portability, an asynchronous signal handler should only:
*make calls (that succeed) to the function signal
*assign values to objects of type volatile sig_atomic_t
*return control to its caller

If the signal reports an error within the program (and the signal is not asynchronous), the signal handler can terminate by calling abort, exit, or longjmp.

Member functions

*int raise(int sig). This raises a signal artificially.

*psignal(int sig, const char *s), outputs to stderr a string representation of a signal number. It is in 4.3BSD, Solaris and Linux, but is not specified by POSIX or SUS.

On the same systems, string.h contains the non-standard strsignal(int sig) which operates analogously to strerror.

*void* signal(int sig, void (*func)(int)), sets the action taken when the program receives the signal sig. If the value of func is SIG_DFL, default handling for that signal will occur. If the value of func is SIG_IGN, the signal will be ignored. Otherwise func points to a "signal handler" function to be called when the signal occurs.

The function func may terminate by executing a return statement or by calling the abort, exit or longjmp functions. If func executes a return statement, and the value of sig was SIGFPE or any other implementation-defined value corresponding to a computational exception, the behavior is undefined. Otherwise, the program will resume execution at the point it was interrupted. If the function returns and the return request can be honored, the signal function returns the value of func for the most recent call to signal for the specified signal sig. Otherwise a value of SIG_ERR is returned and a positive value is stored in errno.

If the signal occurs other than as the result of calling the abort or raise function, the behavior is undefined if the signal handler calls any function in the standard library other than the signal function itself (with a first argument of the signal number corresponding to the signal that cause the invocation of the handler) or refers to any object with status storage duration other than by assigning to a static storage duration variable of type volatile sig_atomic_t. Furthermore, if such a call to the signal function results in a SIG_ERR return, the value of errno is indeterminate. [http://www.xgc.com/manuals/xgclib/c1632.html]

Member types

typedef i-type sig_atomic_t

Member macros

*SIG_DFL - Used to set default signal handling.
*SIG_IGN - Used to handle a signal by ignoring it.
*SIG_ERR - A number used for errors.

Member constants

External links

* [http://www.dinkumware.com/manuals/?manual=compleat&page=signal.html dinkumware's manual on signal.h]
* [http://www.xgc.com/manuals/xgclib/c1632.html XGC's manual for signal.h]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • signal — signal, aux [ siɲal, o ] n. m. • 1540; « signe distinctif, cachet » déb. XIIIe; réfect., d apr. signe, de seignal; bas lat. signale, neutre subst. de signalis « qui sert de signe » 1 ♦ Signe convenu (geste, son...) fait par qqn pour indiquer le… …   Encyclopédie Universelle

  • Signal — Signal, signals, signaling, or signalling may refer to: Scientific concepts * Signal (electrical engineering), a physical quantity that can carry information. * Signal processing, the field of techniques used to extract information from signals * …   Wikipedia

  • Signal — Sig nal, a. [From signal, n.: cf. F. signal[ e].] 1. Noticeable; distinguished from what is ordinary; eminent; remarkable; memorable; as, a signal exploit; a signal service; a signal act of benevolence. [1913 Webster] As signal now in low,… …   The Collaborative International Dictionary of English

  • signal — SIGNÁL, signale, s.n. (Rar) 1. Semnal convenţional emis de o sirenă, de un fluier etc. 2. Fluier mic de metal (cu care se dau aceste semnale convenţionale). – Din fr. signal. Trimis de LauraGellner, 22.07.2004. Sursa: DEX 98  SIGNÁL s. v.… …   Dicționar Român

  • Signal.h — Стандартная библиотека языка программирования С assert.h complex.h ctype.h errno.h fenv.h float.h inttypes.h iso646.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stdbool.h stddef.h stdint.h stdio.h stdlib.h …   Википедия

  • Signal FM — Langue Français, Créole Pays  Haiti !Haïti Statut …   Wikipédia en Français

  • signal — sìgnāl m <G signála> DEFINICIJA 1. znak koji služi da bi se dojavila poruka ili upozorenje [crvena krpa predstavljat će signal za upozorenje] 2. stvar, znak i sl. koji ukazuje da će se nešto početi događati [dim iz vulkana je signal moguće… …   Hrvatski jezični portal

  • Signal — Sn std. (17. Jh.) Entlehnung. Entlehnt aus frz. signal m., zu l. sīgnālis bestimmt, ein Zeichen zu geben , zu l. sīgnum Zeichen, Kennzeichen, Merkmal . Verb: signalisieren.    Ebenso nndl. signaal, ne. signal, nfrz. signal, nschw. signal, nnorw.… …   Etymologisches Wörterbuch der deutschen sprache

  • Signal — Saltar a navegación, búsqueda Signal era órgano de propaganda principal publicado no tanto por los nazis cuanto por el Ejército Alemán durante la Segunda Guerra Mundial. Era famoso por sus fotografías en color de calidad, lo que en la época… …   Wikipedia Español

  • signal — sub. m. Signe que l on donne pour servir d advertissement. Faire un signal. donner le signal. à ce signal ils mirent tous l espée à la main. ils tirerent trois coups de canon pour signal. On leur fit plusieurs signaux. ils firent les signaux dont …   Dictionnaire de l'Académie française

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”