I'm trying to get the pid of the process that sent a certain signal to the receiver. Code snippet follows.
OS is linux , kernel 2.6.x. gcc version 3.3.3 complains during compilation about the undefined siginfo_t member in the signal callback. Can't find a lot of information on this but know it must work. What includes or libraries am I missing (if that's the issue)?
Code:
sigfillset(&signals);
sigdelset(&signals,SIGUSR2);
sigdelset(&signals,SIGINT);
sigdelset(&signals,SIGALRM);
fd = openuserlog("/tmp/testlog");
dogetallgs(fd,argc,argv);
passer.sa_flags = SA_RESTART | SA_SIGINFO;
passer.sa_sigaction = handleAlert;
passer.sa_mask = signals;
sigaction(SIGUSR2,&passer,NULL);
signal(SIGALRM,handleAlarm);
while (1) {
waitpid(-1,NULL,WNOHANG);
sigsuspend(&signals);
if (sigpid != 3) {
writeuserlog(fd,"Knock received. Count at %d\nSetting reset alarm for %d.\n",sigpid,IMTIME);
alarm(IMTIME);
continue;
}
if (sigpid == 3) {
if ( (exopen = fork()) == 0) {
writeuserlog(fd,"At this point we would exec the 'knock' driven program in question.\n");
exit(0);
}
alarm(0);
}
}
}
return 0;
}
/*ordinal_correct* needs to go in the handler*/
void handleAlert(int snum, struct siginfo_t *sdata, void *ucon) {
ordinal_determine_correct(sdata->si_pid,&sigpid);
return;
}
OS is linux , kernel 2.6.x. gcc version 3.3.3 complains during compilation about the undefined siginfo_t member in the signal callback. Can't find a lot of information on this but know it must work. What includes or libraries am I missing (if that's the issue)?