Home What is the scope of signals?
Reply: 1

What is the scope of signals?

Zeno Raiser
1#
Zeno Raiser Published in 2018-01-12 19:54:46Z

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?

user3386109
2#
user3386109 Reply to 2018-01-12 20:38:43Z

Signals have process scope. Once you install a handler it remains in effect until either

  • you remove it with another call to sigaction
  • the handler gets called and the SA_RESETHAND flag is set
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.346856 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO