Pause ()

The function is pause()blocked until a signal is received. Assuming that the process received a signal and pause (), whether the signal handler processes to the code following the call pause(), or the result of a sudden?

Example:

void sigusr1_handler() 
{
   // .. handler code
}

void main() 
{
   // .. bind handler to SIGUSR1

   pause(); // wait for SIGUSR1
   // some more code
}

Will "still some code" be executed after completion, sigusr1_handler() or is there a race condition? If so, what is the solution?
 I can think of nothing but lively, but then a pause will not be needed at all.

+6
source share
2 answers

Quoting from the pause help page (2) :

pause() , . pause() -1, errno - EINTR.

, some more code.

+7

; , , , .

, ; , , . , pause , , .

" ":

  • write pipe read .
  • sem_post sem_wait .
  • sigwaitinfo sigtimedwait .
  • pause, :

    while(!signal_handler_finished) pause();
    

    signal_handler_finished volatile sig_atomic_t .

+3

All Articles