C Language Development in Linux (Signal Processing)

Source: Internet
Author: User

[Disclaimer: All Rights Reserved. You are welcome to reprint it. Do not use it for commercial purposes. Contact Email: feixiaoxing @ 163.com]

Signal processing is LinuxProgram. It is the best choice for our system programmers to use signal processing to simulate the interrupt function of the operating system. To use the signal processing function, you must enter a signal processing function. Once the process processes the signals to be processed, the process will immediately process them.

# Include <stdio. h> # include <stdlib. h> # include <signal. h> int value = 0; void func (INT sig) {printf ("I get a signal! \ N "); value = 1;} int main () {signal (SIGINT, func); While (0 = value) sleep (1); Return 0 ;}

To display the signal processing process in Linux, two steps are required. First, enter GCC Sig. c-O sig, and then input. /Sig. Second, restart a console window, enter PS-Aux | grep Sig, and then enter kill-int 2082 after obtaining the PID of SIG. Then we can get the following output.

[Root @ localhost fork] #./Sigi get a signal! [Root @ localhost fork] #

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.