I have to write a function that retrieves some information about some signal handling status. That is if there is a specific handler or the signal is ignored, the signal which are blocked and what flags are activated. In order to do this I use sigaction function. Here is my code:
void show_signal_info(int signal_number){
struct sigaction s;
int nomask=1;
if(sigaction(signal_number, NULL, &s) == -1){
perror("Error getting information of signal");
}else{
printf("Signal name: %s\n",signal_name(signal_number));
printf("Signal mask: ");
for(i=0; i<32; i++){
if(sigismember(s.sa_mask,i) == 1)
printf("%s ",signal_name(i);
printf("%s",nomask ? "None\n" : "\n");
if(s.sa_handler == SIG_DFL)
printf("Default\n");
else if (s.sa_handler == SIG_IGN)
printf("Ignored\n");
else
printf("Handler\n");
[...]
}
}
The problem is that I dont know how to check what flags are on with s.sa_flags? There is some macros similar to those I can use with wait() function or there is other way to do it?
You can test bits, for example: