Re: SIGINT with gtk_main



On Wednesday 21 March 2007 20:59, zz excite it wrote:
[snip]
Hi,

maybe adding this to main

      /*signal(SIGHUP,SIG_IGN); */                    /* ignore SIGHUP */
      /*signal(SIGTERM,signal_handler);*/     /* catch SIGTERM */
      signal(SIGINT,signal_handler);          /* catch SIGINT  */


and using this handler

static void signal_handler(int sig) __attribute__(( __noreturn__ ));
static void signal_handler(int sig)
{
      switch (sig) {
              case SIGINT:
                      puts("SIGINT signal catched");
                      break;
              case SIGTERM:
                      puts("SIGTERM signal catched");
                      break;
      }
      /* Do something useful here */
      exit(EXIT_FAILURE);
}

As puts() is not guaranteed to be async-signal-safe, this is undefined 
behaviour.

Chris




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]