title: What exactly is kqueue's EV_RECEIPT for?
body: <p>The <a href="https://www.freebsd.org/cgi/man.cgi?query=kqueue&amp;apropos=0&amp;sektion=0&amp;manpath=FreeBSD%2010.3-RELEASE%20and%20Ports&amp;arch=default&amp;format=html" rel="noreferrer">kqueue mechanism</a> has an event flag, <code>EV_RECEIPT</code>, which according to the linked man page:</p>
  
  <blockquote>
    <p>... is useful for making bulk changes to a kqueue
              without draining any pending events.  When passed as input,
              it forces <code>EV_ERROR</code> to   always be returned.  When a filter is
              successfully added the data field will be zero.</p>
  </blockquote>
  
  <p>My understanding however is that it is trivial to make bulk changes to a kqueue without draining any pending events, simply by passing 0 for the <code>nevents</code> parameter to <code>kevent</code> and thus drawing no events from the queue. With that in mind, why is <code>EV_RECEIPT</code> necesary?</p>
  
  <p>Some <a href="https://developer.apple.com/library/mac/technotes/tn2050/_index.html" rel="noreferrer">sample code</a> in Apple documentation for OS X actually uses EV_RECEIPT:</p>
  
  <pre><code>kq = kqueue();
  
  EV_SET(&amp;changes, gTargetPID, EVFILT_PROC, EV_ADD | EV_RECEIPT, NOTE_EXIT, 0, NULL);
  (void) kevent(kq, &amp;changes, 1, &amp;changes, 1, NULL);
  </code></pre>
  
  <p>But, seeing as the <code>changes</code> array is never examined after the <code>kevent</code> call, it's totally unclear to me why <code>EV_RECEIPT</code> was used in this case.</p>
  
  <p><strong>Is EV_RECEIPT actually necessary? In what situation would it really be useful?</strong> </p>