title: Select EBADF : which FD is bad?
body: <p>We have a long standing bug in our production code. This is essentially a socket based daemon. It listens to a bunch of filedescriptors using select.</p>
  
  <p>Occasionally (once a day or so), select will return with EBADF.</p>
  
  <p>I have written code to search for the bad filedescriptor, that loops over each fd and calls select on it. These calls never return EBADF. I also tried fstat. They also never return EBADF.</p>
  
  <p>I also rewrote the daemon to use poll. This did not help.</p>
  
  <p>Does anyone have some other ideas ? (apart from i made a dumb mistake, which is all to easy to do with select).</p>