title: Unable to read from filedescriptor, program is killed
body: <p>I am trying to read a filedescriptor with read() but my program freezes there and after a while is <code>Killed</code>. Is there a timeout for reading filedescriptors or a good way to check why this happens? 
  My program uses gadgetfs to read/write from/to USB in user space.
  Thanks!
  This is the code. It's a modified version of the usb.c samle (<a href="http://www.linux-usb.org/gadget/usb.c" rel="nofollow">http://www.linux-usb.org/gadget/usb.c</a>)</p>
  
  <pre><code>struct pollfd ep0_poll;
  ep0_poll.fd = gadgetFS_FD;
  ep0_poll.events = POLLIN | POLLOUT | POLLHUP;
  
  while(){
                  int nPoll = poll(&amp;ep0_poll, 1, 250);    
              if(nPoll == 0)
                  continue;
  
              if (nPoll &lt; 0) {
                  printf("poll failed");          
              }
  
              usb_gadgetfs_event  aoEvent [5];
              ssize_t nRead = read (ep0_poll.fd, &amp;aoEvent, sizeof aoEvent);
  
              if (nRead &lt; 0) {
                  if (errno == EAGAIN) {
                      sleep (1);
                      continue;
                  }
                  printf("ep0 read after poll");
              }
  
                    ...
  
      }
  </code></pre>