Linux network programming---------Signal Big Lecture Hall

Source: Internet
Author: User

1. Introduction to the signal

There is no time in the Linux system to generate a signal. The signal is also called software interruption on Linux,used to notify the process that an asynchronous event has occurred. At the software level is a simulation of the interrupt mechanism, in principle, a process receives a signal and the processor receives an interrupt request can be said to be the same. signal is the only asynchronous communication mechanism in inter-process communication mechanism,a process does not have to wait for the signal to arrive by any action, in fact, the process does not know when the signal will arrive. Processes can send soft interrupt signals to each other via system call Kill. The kernel can also send a signal to the process because of an internal event, notifying the process that an event has occurred. In addition to the basic notification function, the signal mechanismyou can also pass additional information.


2. Four elements of the signal

      • Number: Each type of signal has a unique number in the Linux system. All signals can be viewed via kill-l under the command

      • Signal name: Each signal has a unique signal name in the Linux system, which can be used to view all signals via kill-l at the command.

      • Event: A specific event needs to be met before sending

      • Default processing action: Each signal has a default processing behavior (detailed below)


3. Sharing of Signals:

      • Simple: The signal is the least expensive mechanism in the Linux IPC interprocess communication

      • Cannot carry large amounts of data

      • Need to meet specific events before sending



4. Mechanism of the signal

      • All signals received by each process are sent by the kernel kernel and processed by the kernel in the kernel.


5. Classification of generated signals

    • Keyboard:

      • CTRL + c---> 2 SIGINT

      • CTRL + Z---> SIGSTOP

      • Ctrl+\---> 3 sigquit


    • System calls

      • On the program, kill Sigqueue

    • Software conditions meet

      • Alarm Setitimer Timer


    • Hardware error (program error)

      • Unauthorized access to Memory: Segment error----> SIGSEGV

      • Except 0: Floating point exception----> 8 SIGFPE

      • Error in memory alignment: Bus error---->

    • Command issued

      • Kill

6. How the signal is processed

      • Perform default actions

        • term termination process

        • LGN Ignore Signal

        • Core terminates the process and produces a core file for debugging use

        • Stop Stop (pause) process

        • Cont continue running the process

      • Perform ignore processing

      • Snap: callback function when performing user registration

    • Note: The SIGKILL and sigstop signal processing methods can only be performed by default actions and cannot be ignored and captured.


This article is from the "Sea" blog, be sure to keep this source http://lisea.blog.51cto.com/5491873/1787830

Linux network programming---------Signal Big Lecture Hall

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.