示例#1
0
/* Tell the event loop what to do if SIGINT is received. 
   See event-signal.c. */
void
handle_sigint (int sig)
{
  signal (sig, handle_sigint);

  /* We used to set the quit flag in async_request_quit, which is either
     called when immediate_quit is 1, or when we get back to the event
     loop.  This is wrong, because you could be running in a loop reading
     in symfiles or something, and it could be quite a while before you 
     get to the event loop.  Instead, set quit_flag to 1 here, then mark
     the sigint handler as ready.  Then if somebody calls QUIT before you
     get to the event loop, they will unwind as expected.  */

  quit_flag = 1;

  /* If immediate_quit is set, we go ahead and process the SIGINT right
     away, even if we usually would defer this to the event loop. The
     assumption here is that it is safe to process ^C immediately if
     immediate_quit is set. If we didn't, SIGINT would be really
     processed only the next time through the event loop.  To get to
     that point, though, the command that we want to interrupt needs to
     finish first, which is unacceptable. */
  if (immediate_quit)
    async_request_quit (0);
  else
    /* If immediate quit is not set, we process SIGINT the next time
       through the loop, which is fine. */
      mark_async_signal_handler_wrapper (sigint_token);
}
示例#2
0
文件: event-top.c 项目: gygy/asuswrt
/* Tell the event loop what to do if SIGINT is received. 
   See event-signal.c. */
void
handle_sigint (int sig)
{
  signal (sig, handle_sigint);

  /* We could be running in a loop reading in symfiles or something so
     it may be quite a while before we get back to the event loop.  So
     set quit_flag to 1 here. Then if QUIT is called before we get to
     the event loop, we will unwind as expected.  */

  quit_flag = 1;

  /* If immediate_quit is set, we go ahead and process the SIGINT right
     away, even if we usually would defer this to the event loop. The
     assumption here is that it is safe to process ^C immediately if
     immediate_quit is set. If we didn't, SIGINT would be really
     processed only the next time through the event loop.  To get to
     that point, though, the command that we want to interrupt needs to
     finish first, which is unacceptable. */
  if (immediate_quit)
    async_request_quit (0);
  else
    /* If immediate quit is not set, we process SIGINT the next time
       through the loop, which is fine. */
    mark_async_signal_handler_wrapper (sigint_token);
}
示例#3
0
文件: event-top.c 项目: DonCN/haiku
/* Tell the event loop what to do if SIGINT is received. 
   See event-signal.c. */
void
handle_sigint (int sig)
{
  signal (sig, handle_sigint);

  /* If immediate_quit is set, we go ahead and process the SIGINT right
     away, even if we usually would defer this to the event loop. The
     assumption here is that it is safe to process ^C immediately if
     immediate_quit is set. If we didn't, SIGINT would be really
     processed only the next time through the event loop.  To get to
     that point, though, the command that we want to interrupt needs to
     finish first, which is unacceptable. */
  if (immediate_quit)
    async_request_quit (0);
  else
    /* If immediate quit is not set, we process SIGINT the next time
       through the loop, which is fine. */
    mark_async_signal_handler_wrapper (sigint_token);
}