Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing something basic 1

Status
Not open for further replies.

macd68

Technical User
Nov 7, 2007
115
US
I'm trying to get the pid of the process that sent a certain signal to the receiver. Code snippet follows.

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)?
 
I haven't got my references with me but at a guess sininfo_t is a typedef of a struct so you shouldn't be putting struct in front of it.
 
Arrgh. Thanks. Can't believe I missed that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top