Which of the following experts can see where the problem is?

Source: Internet
Author: User
Which of the following experts can see what the problem is-General Linux technology-Linux programming and kernel information? The following is a detailed description. # Include "apue. h"

Static void sig_quit (int );

Int main ()
{
Sigset_t newmask, oldmask, pendmask;

If (signal (SIGQUIT, sig_quit) = SIG_ERR)
Err_sys ("can't catch SIGQUIT ");

Sigemptyset (& newmask );
Sigaddset (& newmask, SIGQUIT-1 );

If (sigprocmask (SIG_BLOCK, & newmask, & oldmask) <0)
Err_sys ("SIG_BLOCK error ");

Sleep (5 );

If (sigpending (& pendmask) <0)
Err_sys ("sigpending error ");
If (sigismember (& pendmask, SIGQUIT-1) <0)
Printf ("\ nSIGQUIT pending \ n ");

If (sigprocmask (SIG_SETMASK, & oldmask, NULL) <0)
Err_sys ("SIG_SETMASK error ");
Printf ("SIGQUIT unblocked \ n ");

Sleep (5 );
Exit (0 );
}

Static void sig_quit (int signo)
{
Printf ("caught SIGQUIT \ n ");
If (signal (SIGQUIT, SIG_DFL) = SIG_ERR)
Err_sys ("can't reset SIGQUIT ");
}
Press ctrl + \ to output the result:
SIGQUIT pending
Catch SIGQUIT
SIGQUIT unblocked
However, my running result does not output SIGQUIT pending, that is
Catch SIGQUIT
SIGQUIT unblocked
Why?
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.