- 论坛徽章:
- 0
|
# include <sys/types.h>
# include <unistd.h>
# include <stdio.h>
# include <signal.h>
void new_op(int,siginfo_t*,void*);
int main(int argc,char** argv)
{
struct sigaction act;
int sig;
pid_t pid;
pid=getpid();
sig=atoi(argv[1]);
sigemptyset(&act.sa_mask);
act.sa_sigaction=new_op;
act.sa_flags=SA_SIGINFO;
printf("the pid is %d",pid);
if(sigaction(sig,&act,NULL)==-1)
{
printf("install error~!\n");
}
while(1)
{
sleep(2);
printf("wait for signal\n");
}
}
void new_op(int signum,siginfo_t *info,void *myact)
{
printf("the int value is %d",info->si_int);
}
为什么会 install error :! 呢? |
|