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. Linux改变文件属性与权限

    chgrp:改变文件所属用户组 chown:改变文件所有组 chmod:改变文件的权限 一.chgrp(change group的简称) 修改文件所属组:eg:chgrp users install. ...

  2. MySQL的基础(优化)1

    1,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽可能小 2,在可能的情况下,应该尽量把字段设置为NOT NULL,这样在将来执行查询的时候,数据库不用去比较NULL值 3,对于某 ...

  3. 分治——sqtx

    题目描述 Given a string s, partition s such that every substring of the partition is a palindrome. Retur ...

  4. Selenium入门13 cookie的增删改查

    cookie的增删改查: 查询:get_cookies()查询所有cookie,get_cookie(cookie的name)获取单个cookie 删除:delete_cookie(cookie的na ...

  5. IOS 自定义Operation(下载功能)

    一个下载操作就交给一个HMDownloadOperation对象 HMDownloadOperation.h / .m @class HMDownloadOperation; @protocol HM ...

  6. 关于Ubuntu下安装Win8和Win8下安装Ubuntu的注意事项

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/svitter/article/details/32932387 本文出自:http://blog.c ...

  7. 【转】基于JavaMail的Java邮件发送

    http://blog.csdn.net/xietansheng/article/details/51673073 http://blog.csdn.net/xietansheng/article/d ...

  8. R 语言学习日志 1

      1. CSV文件的的读取与写出 2. 数据集筛选 3. 简单随机抽样 sample函数   正文: 1. CSV文件的的读取与写出 文件读取: df2 <- read.table(" ...

  9. CPP-基础:类

    1,成员访问属性 一,对于类的实现来说: private:类内部(包括类域范围内)可访问. protect:类内部(包括类域范围内)或 派生类类内部(包括类域范围内)可访问. public: 类内部和 ...

  10. P1774 最接近神的人_NOI导刊2010提高(02)

    P1774 最接近神的人_NOI导刊2010提高(02) 关于此题为什么可以使用求逆序对的方法来做 假设一个数\(a_i\),且前\(i-1\)个数已经成为单调增的数列. 我们要从前\(a_1\)至\ ...