#include <stdio.h>
#include <signal.h>
int main()
{
sigset_t sig_set;
sigemptyset(&sig_set);
sigaddset(&sig_set,SIGALRM);
if( sigismember(&sig_set,SIGALRM)==1 )
printf(
"SIGALRM has been set\n");
else
printf(
"SIGALRM not been set\n");
signal(SIGALRM,sigusr1_handler);
if(sigprocmask(SIG_BLOCK,&sig_set,
NULL)==-1)
printf(
"fail to set mask\n");
else
printf(
"set mask ok\n");
raise(SIGALRM);
alarm(5);
while(1)
{
printf(
"on\n"); sleep(1); } return 0; }
這個程序因爲對SIGALRM信號進行了屏蔽,因此並無Alarm Clock出來終止進程,但是,這個信號仍是存在的,叫作未決信號,一旦把這個屏蔽去掉,這個信號立馬就蹦出來了,不過同類的信號只能有一個未決信號,其它忽略