signal interrupts reading from queue
I have a process who's main thread reads messages from a SystemV message queue every 5 seconds (because the messages arive in the queue every 5 seconds ) . Between two readings from the queue the main thread is blocked in a read( msgrcv call) from the queue , because there are no messages in the queue for 5 seconds. This process is supposed to be stoped by a signal sent from another process . So it should exit the reading loop when the signal arrives, destroy all resources and end properly. But the signal ,which is caught by the signal handler I installed ( this handler only changes a flag ), interrupts the read (msgrcv call) from the queue so the program stops failing at the msgrcv call and thus it doesn't have time to destroy resources and end properly. How could I fix this? I want the process which catches the signal to end properly, and destroy all resources .. How can I do this ?
|