试验 在一个进程内用 sigprocmask 堵塞 定义在 sigset中的信号
#include "public.h"
void myaction2(int sig,siginfo_t *info,void *reverse)
{
for (int i=0;i<5;i++)
{
printf("myaction2 = %d\n",i);
sleep(1);
}
}
int main()
{
int iFlag=0;
pid_t pid;
union sigval sival_data;
struct sigaction action;
action.sa_sigaction=myaction2;
action.sa_flags=SA_SIGINFO;
sigaction(SIGUSR1,&action,NULL);
pid=fork();
if (-1==pid)
{
printf("fork 进程失败\n");
return -1;
}
if (0==pid)
{
printf("iFlag=%d pid=%d\n",iFlag,getpid());
kill(getpid(),SIGUSR1);
printf("iFlag=%d pid=%d\n",++iFlag,getppid());
kill(getppid(),SIGUSR1);
}
else
if (pid>0)
{
printf("iFlag=%d pid=%d\n",iFlag,getpid());
sleep(8);
}
return 0;
}