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 :


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 ()
{
Sleep();
}
void SignalHandler(int signal)
{
if (signal == SIGABRT)
{
// abort signal handler code
} else
{
// ...
} printf("____ signal: %d \n", signal);
}

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

Send signal

win32 signal的更多相关文章

  1. 转:RTMPDump源代码分析

    0: 主要函数调用分析 rtmpdump 是一个用来处理 RTMP 流媒体的开源工具包,支持 rtmp://, rtmpt://, rtmpe://, rtmpte://, and rtmps://. ...

  2. rtmpdump代码分析 转

    RTMPdump 源代码分析 1: main()函数 rtmpdump 是一个用来处理 RTMP 流媒体的工具包,支持 rtmp://, rtmpt://, rtmpe://, rtmpte://, ...

  3. rpcz VC2010 构建

    rpcz VC2010 构建 rpcz 是应用ZeroMQ和Protobuf开发的RPC. 见: https://github.com/reinferio/rpcz 及 https://code.go ...

  4. 【PHP源码】PHP 函数调用

    title: [PHP 源码]PHP 函数调用 date: 2020-03-30 23:25:00 updated: 2020-04-04 19:57:00 tags: PHP 源码 想法 我以前对于 ...

  5. multiprocessing 让子进程忽略信号,手动关闭子进程

    起因 同事想要写一个代码,主进程中监听SIGINT.SIGTERM信号退出,并关闭启动的子进程,代码类似这样 import signal import sys import time from mul ...

  6. Serial Port Programming using Win32 API(转载)

    In this tutorial we will learn How to communicate with an external device like a microcontroller boa ...

  7. Microsoft Win32 to Microsoft .NET Framework API Map

    Microsoft Win32 to Microsoft .NET Framework API Map .NET Development (General) Technical Articles   ...

  8. python signal信号

    作用:发送和接收异步系统信号 信号是一个操作系统特性,它提供了一个途径可以通知程序发生了一个事件并异步处理这个事件.信号可以由系统本身生成,也可以从一个进程发送到另一个进程. 由于信号会中断程序的正常 ...

  9. python signal(信号)

    信号的概念 信号(signal)--     进程之间通讯的方式,是一种软件中断.一个进程一旦接收到信号就会打断原来的程序执行流程来处理信号. 几个常用信号: SIGINT     终止进程  中断进 ...

随机推荐

  1. c++基础(积少成多)

    1.#include<string> #include<iostream> 这是引用头文件: 2.Using namespace std; 这是引用命名空间,防止同一个命名空间 ...

  2. mysql 5.6 zip安装,启动失败,1067错误

    在使用mysql5.6 zip压缩包安装mysql过程中,启动过程,老是卡在1067启动错误上,翻看网上各种解决方案,卸载干净重装,重启,都不管用. 网上各种教程都是新建 my.ini mysql 配 ...

  3. powershell远程连接

    最近因为工作的需要看了看powershell相关的知识,个人总结了一点有关于powershell远程连接需要做的步骤,希望对别人有所帮助. 使用powershell远程连接,需要进行 设备的配置: 1 ...

  4. PHP:global全局变量的使用

    global全局变量能够让我们更好的去运用,直接上例子: 1.一个函数,获取函数外的内容: 得到的结果: 2.两个函数,函数2获取函数1的全局变量内容:(重点) 结果: 以上就是我的总结啦 END

  5. 【JavaScript 封装库】BETA 1.0 测试版发布!

    /* 源码作者: 石不易(Louis Shi) 联系方式: http://www.shibuyi.net =============================================== ...

  6. POJ-2456 Aggressive cows---最大化最小值(也就是求最大值)

    题目链接: https://vjudge.net/problem/POJ-2456 题目大意: 有n个牛栏,选m个放进牛,相当于一条线段上有 n 个点,选取 m 个点, 使得相邻点之间的最小距离值最大 ...

  7. ABI and ISA

    ABI定义了如何使用ISA. ISA定义了机器码的使用规则. http://www.delorie.com/gnu/docs/gmp/gmp_6.html ABI and ISA ABI (Appli ...

  8. centos6 yum 安装 install c++4.8 gcc4.8

    cd /etc/yum.repos.d wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo yum --enablerep ...

  9. 1006: Hero In Maze

    1006: Hero In Maze 时间限制: 1000 Sec  内存限制: 64 MB提交: 417  解决: 80[提交][状态][讨论版][命题人:外部导入] 题目描述 500年前,Jess ...

  10. AngularJS 外部文件中的控制器其他实例

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...