title: How to select on STDIN_FILENO ignoring signals?
body: <p>Please check the following code</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;termios.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;sys/time.h&gt;
  #include &lt;time.h&gt;
  
  #define CLOCKID CLOCK_REALTIME
  #define SIG SIGRTMIN
  int reset = 0;
  void changemode(int);
  int  kbhit(void);
  int pfds[2];
  
  static void handler(int sig, siginfo_t *si, void *uc)
  {
      write(pfds[1], "reset", 6);
  }
  
  int main(void)
  {
      int ch;
      timer_t timerid;
      struct sigaction sa;
      struct itimerspec its;
      struct sigevent sev;
      long long freq_nanosecs;
      char buf[30];
  
      pipe(pfds);
  
      sa.sa_flags = 0;
      sa.sa_sigaction = handler;
      sigemptyset(&amp;sa.sa_mask);
      if (sigaction(SIG, &amp;sa, NULL) == -1)
      {
          printf("Error\n");
          exit(1);
      }
  
      changemode(1);
  
      sev.sigev_notify = SIGEV_SIGNAL;
      sev.sigev_signo = SIG;
      sev.sigev_value.sival_ptr = &amp;timerid;
      if (timer_create(CLOCKID, &amp;sev, &amp;timerid) == -1)
      {
          printf("Error timer_create");
          exit(1);
      }
  
      its.it_value.tv_sec = 1;
      its.it_value.tv_nsec = 0;
      its.it_interval.tv_sec = its.it_value.tv_sec;
      its.it_interval.tv_nsec = its.it_value.tv_nsec;
  
      if (timer_settime(timerid, 0, &amp;its, NULL) == -1)
      {
          printf("Error timer_settime");
          exit(1);
      }
  
      while(1)
      {
          if (kbhit())
          {
              ch = getchar();
              printf("%d %c\n", ch, ch);
              if (ch == 'q')
              {
                  printf("\nQuitting...\n");
                  break;
              }
          }
          else
          {
              memset(buf, 0, 30);
              read(pfds[0], buf, 6);
              printf("\n%s", buf);
          }
      }
  
      changemode(0);
      return 0;
  }
  
  void changemode(int dir)
  {
      static struct termios oldt, newt;
  
      if ( dir == 1 )
      {
          tcgetattr( STDIN_FILENO, &amp;oldt);
          newt = oldt;
          newt.c_lflag &amp;= ~( ICANON | ECHO );
  
          tcsetattr( STDIN_FILENO, TCSANOW, &amp;newt);
      }
      else
          tcsetattr( STDIN_FILENO, TCSANOW, &amp;oldt);
  }
  
  int kbhit (void)
  {
      fd_set rdfs;
  
      FD_ZERO(&amp;rdfs);
      FD_SET (STDIN_FILENO, &amp;rdfs);
      FD_SET (pfds[0], &amp;rdfs);
  
      select(FD_SETSIZE, &amp;rdfs, NULL, NULL, NULL);
      return FD_ISSET(STDIN_FILENO, &amp;rdfs);
  
  }
  </code></pre>
  
  <p>But whenever the signal SIGRTMIN is generated STDIN_FILENO is set (FD_ISSET) althought i've not entered anything in the terminal. How to make select ignore STDIN_FILENO when SIGRTMIN is generated by the timer?</p>