title: How to set read() to non-blocking mode
body: <p>I have a problem at present when calling read() like this:</p>
  
  <pre><code>unsigned char byData[1024] = {0};
  ssize_t len = read(fd, byData, sizeof(byData));
  </code></pre>
  
  <p>where fd is the file descriptor.</p>
  
  <p>read() is blocking which is not what I want.
  Is there a simple way to set read to non-blocking or time out?
  The code is used with inotify.</p>
  
  <p>Thanks for any help.</p>