The kqueue mechanism has an EV_RECEIPT event EV_RECEIPT , which according to the linked man page:
... useful for making massive changes to kqueue without any pending events. When they are passed as input, it causes EV_ERROR always return. When the filter, the successfully added data field will be null.
My understanding, however, is that it is trivial to make massive changes to kqueue without depleting the pending events, simply passing 0 for the nevents parameter to kevent and thus not causing any events from the queue. With that in mind, why is EV_RECEIPT necessary?
Some sample code in the Apple documentation for OS X actually uses EV_RECEIPT:
kq = kqueue(); EV_SET(&changes, gTargetPID, EVFILT_PROC, EV_ADD | EV_RECEIPT, NOTE_EXIT, 0, NULL); (void) kevent(kq, &changes, 1, &changes, 1, NULL);
But, seeing that the changes array is never examined after kevent , it is completely incomprehensible to me why EV_RECEIPT was used in this case.
Is EV_RECEIPT really necessary? In what situation will it really be useful?
source share