I have a single thread writing a stream of data into files in a directory. The data stream can pause for any length of time just as easily as it writes a continuous trickle of data. It writes one file at a time and whenever the file grows too large, it closes the file and begins a new one. The files should therefore be read in a particular order to reconstruct the stream.
Separately I have another process (possibly several) following the stream of data using inotify to trigger reads. This allows a one-to-many distribution of data as well as the option to replay the stream at any time.
I'm concerned about how to correctly handle the changeover of files in the readers. I don't want the reader to start processing the next file until the last has been completely written to.
Assuming a single directory level inotify watch, are inotify events guarantee to be reported in the order they were generated? They are being generated by a single thread. There is a provable order to them. More specifically, are
IN_CREATE guaranteed to happen in the same order even though they technically apply to different inodes?