title: multiple timer to one process (without linking to rt)
body: <p>is there any way to register multiple timer to a single process? I have tried following code, yet without success. (Use "gcc -lrt" to compile it...). Program output nothing, which should atleast print "test". Is it possibly due to the dependence to linking to rt?</p>
  
  <pre><code>#define TT_SIGUSR1 (SIGRTMAX)
  #define TT_SIGUSR2 (SIGRTMAX - 1)
  #define TIME_INTERVAL_1 1
  #define TIME_INTERVAL_2 2
  
  #include &lt;signal.h&gt;
  #include &lt;time.h&gt;
  
  #include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;linux/unistd.h&gt;
  #include &lt;sys/syscall.h&gt;
  #include &lt;sys/time.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sched.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;setjmp.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;assert.h&gt;
  
  
  timer_t create_timer(int signo) {
      timer_t timerid;
      struct sigevent se;
      se.sigev_signo = signo;
      if (timer_create(CLOCK_REALTIME, &amp;se, &amp;timerid) == -1) {
          fprintf(stderr, "Failed to create timer\n");
          exit(-1);
      }
      return timerid;
  }
  
  void set_timer(timer_t timerid, int seconds) {
      struct itimerspec timervals;
      timervals.it_value.tv_sec = seconds;
      timervals.it_value.tv_nsec = 0;
      timervals.it_interval.tv_sec = seconds;
      timervals.it_interval.tv_nsec = 0;
  
      if (timer_settime(timerid, 0, &amp;timervals, NULL) == -1) {
          fprintf(stderr, "Failed to start timer\n");
          exit(-1);
      }
      return;
  }
  
  void install_sighandler2(int signo, void(*handler)(int)) {
      struct sigaction sigact;
  
      sigemptyset(&amp;sigact.sa_mask);
      sigact.sa_flags = SA_SIGINFO;
      //register the Signal Handler
      sigact.sa_sigaction = handler;
  
      // Set up sigaction to catch signal first timer
      if (sigaction(signo, &amp;sigact, NULL) == -1)
  
      {
          printf("sigaction failed");
          return -1;
      }
  }
  
  void install_sighandler(int signo, void(*handler)(int)) {
      sigset_t set;
      struct sigaction act;
  
      /* Setup the handler */
      act.sa_handler = handler;
      act.sa_flags = SA_RESTART;
      sigaction(signo, &amp;act, 0);
  
      /* Unblock the signal */
      sigemptyset(&amp;set);
      sigaddset(&amp;set, signo);
      sigprocmask(SIG_UNBLOCK, &amp;set, NULL);
  
      return;
  }
  
  
  void signal_handler(int signo) {
      printf("receiving sig %d", signo);
  }
  
  int main()
  {
      printf("test");
      timer_t timer1 = create_timer(TT_SIGUSR1);
      timer_t timer2 = create_timer(TT_SIGUSR2);
  
      set_timer(timer1, TIME_INTERVAL_1);
      set_timer(timer2, TIME_INTERVAL_2);
  
      install_sighandler2(TT_SIGUSR1, signal_handler);
      install_sighandler(TT_SIGUSR2, signal_handler);
  
      while (1)
          ;
      return 0;
  }
  </code></pre>