Runtime Library Reference
· Constants
· Data types
Standard C
· assert.h
· complex.h
· ctype.h
· fenv.h
· float.h
· locale.h
· math.h
· setjmp.h
· signal.h
· stdarg.h
· stddef.h
· stdio.h
· stdlib.h
· string.h
· time.h
Standard C++
· IOstream
· new
Win32
· gc.h
DOS, DOS32, Win16
· bios.h
· cerror.h
· disp.h
· dos.h
· dos.h part 2
· emm.h
· handle.h
· int.h
· msmouse.h
· sound.h
· swap.h
· tsr.h
· winio.h
Other C
· bitops.h
· conio.h
· controlc.h
· direct.h
· fltpnt.h
· io.h
· page.h
· process.h
· search.h
· sys\stat.h
· tabsize.h
· trace.h
· utime.h
· unmangle.h
· util.h
Other C++
· regexp.h
· class complex
|
signal.h
- Header
- signal.h
- Prototype
- int raise(int sig);
- Description
- raise issues a signal to the executing program. The signal type,
sig, is discussed in the signal description. When the signal is
raised by the raise function call, the current signal-handling
routine will be called. See signal()
for a complete description.
- Return Value
- Returns 0 if successful, otherwise returns a non-zero value.
- Compatibility
- DOS Windows 3.x Phar Lap DOSX Win32
- See Also
- signal
- Example
-
/* Example for raise
Also demonstrates signal
*/
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
void div_zero (int val)
{
printf("Divide by zero detected!\n");
exit(EXIT_FAILURE);
}
int main()
{
float numerator = 3.0F, denominator = 0.0F;
if (signal(SIGFPE, div_zero) == SIG_ERR)
{
perror ("Could not set signal SIGFPR");
abort ();
}
if (denominator == 0.0F)
raise(SIGFPE);
else
printf("The result of the division is %g\n",
numerator / denominator);
return EXIT_SUCCESS;
}
- Output
-
Divide by zero detected!
- Header
- signal.h
- Prototype
- void (* signal(int sig, void (__cdecl *handler)(int)))(int);
- Description
- signal allows a program to define how signals from the operating
system are handled. Argument sig must be one of these constants:
| Constant | Description
|
| NSIG
| The number of signals
|
| SIGABRT
| Abnormal termination
|
| SIGBREAK
| Control-break
|
| SIGFPE
| Floating-point error
|
| SIGILL
| Illegal instruction
|
| SIGINT
| Interrupt
|
| SIGSEGV
| Segment violation
|
| SIGTERM
| Terminate (CTRL+ C)
|
The following macros are special values for handler:
| Macro | Description
|
| SIG_DFL
| Handled in the default manner.
|
| SIG_IGN
| Ignored the signal.
|
signal sets the response. handler must be declared with C
linkage. When a signal occurs, the signal's behavior is reset to
SIG_DFL, the function for signal is called and sig is passed to it.
- Return Value
- Returns the previous value of handler. A return value of SIG_ERR
indicates an error and errno is set.
- Compatibility
- DOS Windows 3.x Phar Lap DOSX Win32
- See Also
- raise
|