3

I am monitoring file system changes in a specific directory using the OSX FSEventStream. I was looking at the documentation here and I found an interesting flag described, kFSEventStreamCreateFlagIgnoreSelf.

According to the documentation using this flag the FSEvents framework won't notify you for "events that were triggered by the current process."

This sounds great. It is exactly what I want, but in practice I have found that I still get some events that were triggered by the current process.

In my limited testing, if the monitoring process creates a new file, or renames and existing file a event is still triggered. While at least some modifications of existing files don't trigger events.

Based upon the limited documentation (and the name of the flag), I would NOT expect any events to triggered by the current process.

So my question is two fold: -- Is this expected behavior? I am afraid if I count on the behavior as it exists, that it might be unintentional and in the future it might change out from underneath me.

Second: -- If it is, does anyone know which events I can expect to still be delivered when using this flag.

John Bowers
  • 1,695
  • 1
  • 16
  • 26

2 Answers2

3

I have noticed that when using this flag, any file changes I make in my process are not sent to me as events. If I do not get any external events after that, my last recorded eventId (for use when I create the stream the next time) will be earlier than the events I did not get so I will see those events the next time I start my process, in the event history dump.

I'm sorry that this is not much of an answer, but it is something that I observed that might help explain what you are seeing.

hvanbrug
  • 1,291
  • 2
  • 12
  • 25
  • 1
    This should be a comment, not an answer. I recognize you don't have enough rep to make comments yet, but posting answers instead is not the best idea (they'll probably get flagged). – GraphicsMuncher Dec 06 '12 at 02:22
  • its documented in header file. Do you know how to handle this ? – Parag Bafna Mar 15 '18 at 16:47
2

I also observed not effect by setting the kFSEventStreamCreateFlagIgnoreSelf flag.

However, setting both the kFSEventStreamCreateFlagMarkSelf and the kFSEventStreamCreateFlagIgnoreSelf (using bitwise OR (|)) did the trick for me. I no longer get notifications about files (in my case, documents) my application saved.

kFSEventStreamCreateFlagMarkSelf is available since OS X 10.9.

osxdirk
  • 560
  • 6
  • 11