title: Keyboard signal handling, adding parameters to callback handler function (Ubuntu, intel)
body: <p>I have this code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  
  // Define the function to be called when ctrl-c (SIGINT) signal is sent to process
  void
  signal_callback_handler(int signum)
  {
     printf("Caught signal %d\n",signum);
     // Cleanup and close up stuff here
  
     // Terminate program
     exit(signum);
  }
  
  int main()
  {
     // Register signal and signal handler
     signal(SIGINT, signal_callback_handler);
  
     while(1)
     {
        printf("Program processing stuff here.\n");
        sleep(1);
     }
     return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>Is there a way to pass an extra argument in the callback function?
  Something like:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  
  // Define the function to be called when ctrl-c (SIGINT) signal is sent to process
  void
  signal_callback_handler(int signum, int k)
  {
  
     k++; // Changing value of k
  }
  
  int main()
  {
     int k = 0;
     // Register signal and signal handler
     signal(SIGINT, signal_callback_handler(k);
  
     while(1)
     {
        printf("Program processing stuff here.\n");
        printf(" blah %d\n", k);
        sleep(1);
     }
     return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>Thank you</p>