Reputation: 217
What is the scope of a signal after I install it??
For example if I have in a function called A this code:
sa.sa_handler = &handle_manager_bd;
sa.sa_flags = SA_NODEFER | SA_RESTART;
sigemptyset(&my_mask);
sa.sa_mask = my_mask;
sigaction(SIGUSR1, &sa, NULL);
If after this i call B, which is another function in the same program, that process will get the signal and do the action specified by handle_manager_bd
right??
Another example which i would like to understand is as follows: if I have installed the handler in a function A like before and after that I call a function C, which is contained in a header file like "c.h"
included by the program which contains A with #include "c.h"
, if I don't install the signal handler in the function C the signal will be recognized because i already installed it in A or should i put again the code above in the function C like i did for A?
Upvotes: 1
Views: 535
Reputation: 34829
Signals have process scope. Once you install a handler it remains in effect until either
sigaction
SA_RESETHAND
flag is setUpvotes: 2