title: Problem handling file I/O with libevent2
body: <p>I worked with libevent2 for some time, but usually I used it to handle network I/O (using sockets). Now I need to read many different files so I also wanted to use it. I created this code:</p>
  
  <pre><code>int file = open(filename, O_RDONLY);
  struct event *ev_file_read = event_new(ev_base, file, EV_READ | EV_PERSIST, read_file, NULL);
  
  if(event_add(ev_file_read, NULL))
          error("adding file event");
  </code></pre>
  
  <p>Unfortunately it doesn't work. I get this message when trying to add event:</p>
  
  <blockquote>
    <p>[warn] Epoll ADD(1) on fd 7 failed.  Old events were 0; read change was 1 (add); write change was 0 (none): Operation not permitted
    adding file event: Operation not permitted</p>
  </blockquote>
  
  <p>The file exists and has rights to read/write. </p>
  
  <p>Anyone has any idea how to handle file IO using libevent? I thought also about bufferred events, but in API there's only function bufferevent_socket_new() which doesn't apply here.</p>
  
  <p>Thanks in advance.</p>