2 ms·
I think the issue, ultimately, is buffering. Kernel interfaces that can't preallocate space at request time are problematic. If you can allocate space sufficien
by wahern 8y ago
I think the issue, ultimately, is buffering. Kernel interfaces that can't preallocate space at request time are problematic. If you can allocate space sufficient to store the event(s) at the same time that you request notification, error handling is easy and obvious from a design perspective. Unbounded, asynchronous buffering in kernel space is simply a non-starter unless you don't care about consistency and reliability. Linux developers generally follow (coincidentally?) the GNU directive[1] of lazy, dynamic allocation, and it's why Linux interfaces can be so problematic and why everybody throws up their hands when one raises concerns about OOM handling.
The reason EVFILT_VNODE works where inotify doesn't is precisely because EVFILT_VNODE requires an open file descriptor, which indirectly behaves as a preallocated buffer for storing pending events. But just like with signals, like events are coalesced and ordering can be lost.
I think the most straight-forward solution to fork notifications is to block the forking process if the event can't be enqueued. That might be the only proper solution, period, if you want guaranteed delivery with the new PID. That creates the potential for deadlocking, but that already exists with other facilities like file locking, pipes, etc.
[1] https://www.gnu.org/prep/standards/standards.html#index-arbitrary-limits-on-data https://www.gnu.org/prep/standards/standards.html#index-arbi...