win32 signal

时间:2014-02-27 17:55:28   收藏:0   阅读:692

The signal function enables a process to choose one of several ways to handle an interrupt signal from the operating system. The sig argument is the interrupt to which signal responds; it must be one of the following manifest constants, which are defined in SIGNAL.H.

 

sig value

Description

SIGABRT

Abnormal termination

SIGFPE

Floating-point error

SIGILL

Illegal instruction

SIGINT

CTRL+C signal

SIGSEGV

Illegal storage access

SIGTERM

Termination request

If sig is not one of the above values, the invalid parameter handler is invoked, as defined in Parameter Validation . If execution is allowed to continue, this function sets errno to EINVALand returns SIG_ERR.

By default, signal terminates the calling program with exit code 3, regardless of the value of sig.

 

Example :

bubuko.com,布布扣
int main(void)
{    

    typedef void (*SignalHandlerPointer)(int);

    SignalHandlerPointer previousHandler;
    previousHandler = signal(SIGABRT, SignalHandler);
    previousHandler = signal(SIGINT, SignalHandler);
    previousHandler = signal(SIGTERM, SignalHandler);
    previousHandler = signal(SIGBREAK, SignalHandler);

    //abort();
    while (1)
    {
        Sleep(100);
    }
bubuko.com,布布扣
bubuko.com,布布扣
void SignalHandler(int signal)
{
    if (signal == SIGABRT)
    {
        // abort signal handler code
    } else 
    {
        // ...
    }

    printf("____ signal: %d  \n", signal);
}
bubuko.com,布布扣

 

http://msdn.microsoft.com/en-us/library/xdkz3x12.aspx

 

Send signal

win32 signal,布布扣,bubuko.com

原文:http://www.cnblogs.com/iclk/p/3560081.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!