01-25-2012
6,
0
Join Date: Sep 2008
Last Activity: 7 May 2013, 6:30 PM EDT
Posts: 6
Thanks Given: 0
Thanked 0 Times in 0 Posts
handling signals without race conditions
Greetings,
I am writing a small program in C on UNIX, in which I am using (POSIX reliable) signals.
1. Suppose I have a signal : SIGX, and the corresponding signal handler : sigx_handler.
It is possible to receive SIGX in my process, and, while executing sigx_handler, to receive
again SIGX and to run again sigx_handler ?
What happens then ? sigx_handler (1st run) is interrupted, then it runs sigx_handler (2nd run),
then it resumes sigx_handler (1st run) ?
Is it possible to block SIGX, while running sigx_handler, and avoiding race conditions (in the C
code) in sigx_handler ? (That is, to run sigx_handler without interrupting it.) How to code this ?
I guess this implies some atomic operations...
2. Suppose my program handles SIGX, SIGY, SIGZ, using sigx_handler, sigy_handler, sigz_handler.
How to block, without race conditions, SIGY and SIGZ signals, when I enter SIGX handler (that is,
when I run sigx_handler) ?
Thank you.