void (*signal(int iSignal, void (*pfnInterrupt) (int [, int ] ))) (int);
Signal Macro Table
Macro | Description | Value |
SIGINT | Interrupt Ctrl-C | 2 |
SIGILL | Illegal Instruction | 4 |
SIGFPE | Floating-point Exception | 8 |
SIGSEGV | Segment Violation | 11 |
SIGTERM | Termination Request | 15 |
SIGBREAK | Ctrl-Break | 21 |
SIGABRT | Abnormal Termination Abort | 22 |
Handler Macro Table*
Macro | Description | Value |
SIG_ERR | Signal error value | 1 |
SIG_DFL | Default handler | 0 |
SIG_IGN | Ignore signal | 1 |
SIG_GET | Return the current value | 2 |
SIG_SGE | Signal gets error | 3 |
SIG_ACK | Acknowledge | 4 |
* Note: These macros are replaced by function pointers, some of which may not exist on all platforms. All of these are defined in Visual C++ 2008.
#include <iostream> #include <csignal> void InterruptHandler(int iArgument) { std::cout << "Inside Handler" << std::endl; std::cout << "Handler Argument = " << iArgument << std::endl; } int main() { using namespace std; void (*pfnOldHandler)(int); pfnOldHandler = signal(SIGTERM, InterruptHandler); int iReturnValue = raise(SIGTERM); cout << "Return value = " << iReturnValue << endl; return 0; }
© 20072025 XoaX.net LLC. All rights reserved.