title: Passing user data with timer_create
body: <p>I am using <code>timer_create</code> to create a timer in Linux. The callback prototype is: </p>
  
  <pre><code>static void TimerHandlerCB(int sig, siginfo_t *extra, void *cruft)
  </code></pre>
  
  <p>How can i pass user data so that i can receive the same in the callback called after timer expiry. </p>
  
  <p>Here's my sample code: </p>
  
  <pre><code>int RegisterTimer(iDiffInTime)
  {
      struct sigaction sa; 
      sigemptyset(&amp;sa.sa_mask);
      sa.sa_flags = SA_SIGINFO;   /*call our handler*/
      sa.sa_sigaction = TimerHandlerCB;/*Event handler to be called after timer expires*/ 
      if(sigaction(SIGRTMAX, &amp;sa, NULL) &lt; 0)
      {
          perror("sigaction");
          return 1;
      }
      // Setup the timer
      sigevent sigev;
      timer_t timerid = 0;
  
      memset(&amp;sigev, 0, sizeof(sigev));
  
      sigev.sigev_notify          = SIGEV_SIGNAL;
      sigev.sigev_signo           = SIGRTMAX;
      sigev.sigev_value.sival_ptr = &amp;timerid;
  
      timer_t timerid;
  
      if (timer_create(CLOCK_REALTIME, &amp;sigev, &amp;timerid) == 0)
      {
          printf("Timer created\n");
          struct itimerspec itval, oitval;
  
          itval.it_value.tv_sec = iDiffInTime * 1000;
          itval.it_value.tv_nsec = 0;
          itval.it_interval.tv_sec = 0;
          itval.it_interval.tv_nsec = 0;
  
                //Populate handles required in TimerCallback
                Display_Handle hDisplay = ......//
                Buffer_Handle hBuf = .....//
          if (timer_settime(timerid, 0, &amp;itval, &amp;oitval) != 0)
          {
              perror("time_settime error!");
              return 1;
          }
      } 
      else 
      {
          perror("timer_create error!");
      }
      return 0
  }
  </code></pre>
  
  <p>Where do I pass <code>hDisplay</code> &amp; <code>hBuf</code> so that I can receive them back in <code>TimerHandlerCB</code>?</p>