- 论坛徽章:
- 0
|
- #include<unistd.h>
- #include<signal.h>
- void show_handler(struct sigaction * act)
- {
- switch (act->sa_flags)//这里出错,我强制类型转换也不行
- {
- case SIG_DFL:
- printf("Dault action\n");
- break;
- case SIG_IGN:
- printf("Ignore the signal\n");
- break;
- default:
- printf("0x%x\n",act->sa_handler);
- }
- }
- main()
- {
- int i;
- struct sigaction act,oldact;
- act.sa_handler = show_handler;
- act.sa_flags = SA_ONESHOT|SA_NOMASK;
- sigaction(SIGUSR1,&act,&oldact);
- for(i=5;i<15;i++)
- {
- printf("sa_handler of signal %2d =",i);
- sigaction(i,NULL,&oldact);
- }
- }
复制代码
编译时提示:
sigaction.c: In function `show_handler':
sigaction.c:7: pointers are not permitted as case values
sigaction.c:10: pointers are not permitted as case values
sigaction.c: In function `main':
sigaction.c:21: warning: assignment from incompatible pointer type |
|