chinaunix网友2010-10-22 16:02
学习了你的,关于不能handle 的问题,我注释了一行code就可以了,你把信号集都block了,那么里面的INT当然就没有出来了哈~~ 慢慢学习你的,我的邮箱,大家互相学习哈mrbone9@gmail.com
#include
#include
#include
sigjmp_buf sigBuf;
void FunB()
{
printf("Enter FunB!\n");
printf("Exit FunB!\n");
}
void FunA()
{
printf("Enter FunA!\n");
call();
printf("Exit FunA!\n");
}
int main(int argc,char *argv[])
{
int iRet = 0;
struct sigaction act;
sigset_t stSig;
sigemptyset(&stSig);
sigaddset(&stSig, SIGINT);
//sigprocmask(SIG_BLOCK, &stSig, NULL);
act.sa_handler = FunB;
act.sa_flags = SA_INTERRUPT;
sigemptyset(&act.sa_mask);
if (sigaction(SIGINT,&act,NULL) != 0)
{
perror("sigaction");
}
iRet = sigsetjmp(sigBuf,1);
if (0 == iRet)
{
kill(getpid(),SIGINT);
FunA();
}
else if (iRet != 0)
{
printf("program close!\n");
}
return 0;
}