File Alteration Monitor. The program fam is a server that processes communicate with. Your app needs to link with libfam, register the files or directories you want to monitor, and check back for updates or just sleep waiting to be awoken by a change. Oh, and fam has to be running, and it has to use the portmap service.
On my RedHat ES system, the man page for the fam server was installed, as was a sample /etc/conf and the libfam library, but there was no fam(3X) manpage installed. Fortunately that's fairly easy to find on the internet.
There are a number of similar tools for this kind of monitoring. Most, like fam, have the advantage that the kernel is doing the real work here and everything else can just take a nap waiting for something to happen to the items of interest. That's obviously more efficient ("betterer") than brute force polling.
There are possible security concerns, which are covered in the fam man page, but as it says:
Note that fam never opens the files its monitoring, and cannot be used by a rogue client to read the contents of any file on the system. fam only gives out the names of monitored files, and only monitors files which the client can stat(1M). Users can stat a file without having read permission on it as long as they have search permission on the directory containing it.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2011-03-20 Tony Lawrence