Question

I need to monitor events on a regular file using file descriptors. I'm working on a machine with CentOS 4.1, and kernel version 2.6.18.128.

After realizing that regular file cannot be monitored using epoll, I found this task can be accomplished using inotify. However, I read elsewhere that the required library interfaces for inotify were added to glibc in version 2.4, and my machine has version 2.3.4 installed. So my kernel has inotify support by not glibc. Unfortunately, I cannot update glibc to a newer version because it would break certain other parts of the project.

So my questions are:

  1. Can I still use inotify to monitor regular file? Could I get a newer version of glibc and place it at a local folder(relative to my code), include the path in my Makefile and use calls associated with inotify? If so, what kind of problems could I run into?
  2. An alternative could be using fstat, by keeping track of the st_mtime member of the struct stat structure. Any caveats against taking this route?

If my questions reveal any lack of understanding with these concepts please bear with me as I just started using them.

Was it helpful?

Solution

For 2 glibc see the following post: Multiple glibc libraries on a single host

Otherwise inotify seems straight forward solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top