[Mono-osx] An open letter to the OS X Mono group.

Louis R. Marascio louis at fitnr.com
Sat Apr 7 08:55:37 EDT 2007


Inline ...

Andreas Frber <andreas.faerber at web.de> wrote:
>My findings seemed to indicate that the root of these problems was  
>deeper than the firing of the managed events: Using test code I  
>shared with Geoff a change to a file (length, contents, last write)  
>did not trigger a kevent event on the directory's file descriptor. I  
>would be fine with a solution like in my test implementation where I  
>determine whether a directory or a single file should be monitored  
>and then use the respective file descriptor for kevent.

You are correct, but I don't think I was completely clear in my original
message. I wasn't suggesting that the error was in the handling of the
managed call backs.

I hacked KeventWatcher to open a file rather than a directory, and to
pass that fd to kevent. In this situation, modifications to the file
were picked up properly. However, if KeventWatcher opens a directory and
passes that to kevent then I CAN get a Changed event, but only if I edit
the file with vi. Some changes don't seemt o make it up the kevent pipe.
So, I'm not saying its an issue with the firing of the actual Changed
event in managed code. I'm saying the underlying kevent doesn't fire,
when watching a directory, unless I use vi (not exclusively, but this is
what I used to test).

>The remaining problem then is: How do we handle wildcards? Currently  
>we have a 1:1 mapping of FileSystemWatchers to file descriptors. But  
>what if a user wants to monitor a directory with hundreds of files?  
>The commented out part of my test implementation shows that we are  
>limited to 255 open file descriptors in whole. According to my  
>reading this is what Linux software like inotify and the like handle  
>- but nothing comparable seems to be available for OS X except some  
>hacky ways of accessing the undocumented internals of Tiger's  
>Spotlight engine. And Finder's FSNotify seems to be an even worse way  
>of detecting changes. So kevent seems to be our best bet for now -  
>it's just the question of how to use it.

The only way we can make this work is by opening a directory. We can't
open each file within a directory. From my Googling this is how it
should be done and is discussed on the Apple developer mailing lists.
The reason for this is straightforward and is as you identified, there
is a rather low limit on the number of open file descriptors per
process.

The mystery stands: when KeventWatcher opens a directory, why does
kevent fire only if I use vi to edit a file and not if I use echo or cat
to write data to a file.

>I remember reading a reference to XSP in the ChangeLog so this is  
>likely to affect Mono's ASP.NET implementation, not just some  
>minor .NET based applications.

This seems to make sense if the ASP.NET bits are auto-reloading pages,
classes, and other what-nots. 

Louis
-- 
Louis R. Marascio - www.fitnr.com
... fixed in the next release ...


More information about the Mono-osx mailing list