The concept of signal of process and signal

Source: Internet
Author: User
Tags signal handler

signal : communication mechanism between process and process

Signal is software interrupt

Signal is an asynchronous event

Signal Source: Kernel generation, common signal Kill (), raise (), Alarm (), SetTimer (), etc.

Kill-
View Linux all signals a total of 64 1-31 non-real-time signal send signal may be lost, does not support signal queuing
32-64 Real-time signal

Process processing Signal :

  Ignore signal

Sigkill and sigstop can never be ignored.

Ignoring hardware exceptions

SIGUSER1 and SIGUSER2 Two signals are ignored during process startup

Perform the default action

Each signal has a default action, and most signal actions are termination signals.

Capture Signal

Tells the signal that the kernel is calling its own handler function.

Sigkill and Sigstop cannot be captured.

signal function signal Registration function void (*signal (int signo,void(*func) (int))) (int); parameter signo the signal value to be registered 1-thefunc  signal handler function pointer /IGNORE signal sig_ign/ default signal sig_ Del returns SIG_ERR if the signal handler pointer is successfully returned

Labels

#include <unistd.h>#include<stdlib.h>#include<signal.h>#include<stdio.h>voidSet_signal (intSigno) {printf ("pid:%d,signo:%d\n", Getpid (), signo);}intMain () {//SIGTSTP is CTRL + Z    if(Signal (sigtstp,set_signal) = =Sig_err) {printf ("Set signal Error"); }    //Ctrl + C    if(Signal (sigint,set_signal) = =Sig_err) {printf ("Set signal Error"); }    intI=0;  while(i< -) {printf ("I:%d\n", i++); Sleep (1); }    return 0;}

The concept of signal of process and signal

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.