I. Process and signal unreliable issues

Source: Internet
Author: User

Whether the process can receive processing signals during processing, the same signal/different signals

Labels

#include <signal.h>#include<stdio.h>#include<stdlib.h>#include<unistd.h>voidSet_signal (intSigno) {    if(Signo = =SIGINT) {printf ("%d catch sigint\n", Getpid ()); Sleep (5); printf ("Process the SIGINT finished\n"); }    if(signo==SIGTSTP) {printf ("%d catch sigtstp\n", Getpid ()); Sleep (5); printf ("Process the SIGTSTP finished\n"); }}intMain () {if(Signal (sigint,set_signal) = =Sig_err) {printf ("Signal error\n"); return 1; }    if(Signal (sigtstp,set_signal) = =Sig_err) {printf ("Signal error\n"); return 1; }        //Pause Wait Signal     while(1) pause (); }

Compile execution

Process processing in the sending of the same signal, first send CTRL +cin the Send Ctrl + C.catch  SIGINT^cprocess the SIGINT finished  3267Catch  sigintprocess the SIGINT finished process to send different signals, first send Ctrl+C in the send Ctrl +Zcatch  SIGINTcatch  sigtstpprocess the SIGTSTP finishedprocess the SIGINT finished

Conclusion

Process processing sends the same signal/different signals will still be processed, but more than 2 processes will block

I. Process and signal unreliable issues

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.