C read mtime of a text file from application

I was wondering if it's possible to read the editing time of a specific text file in the system from an application software, particularly in C.

The idea is to read a text file one it has been edited by an external application.

Thanks!
 
A little more complicated perhaps but you may also want to have a look at kqueue(2).

Without knowing kqueue(2), i second that. From an architectural point of view, polling is bad. It wastes resources. Most modern operating systems provide means for getting notified of changes, in FreeBSD, this is kqueue(2). So, if your application is specific to FreeBSD, use this. If you aim for portability (e.g. with Linux' inotify), use a library, there are some options that encapsulate these notifications in a platform-independent manner (falling back to polling themselves if nothing else works).
 
Thanks for the answers!

I shall be checking out both stat and kqueue... in my case I shall be working only on FreeBSD systems, so from what you have told I guess I'll go for the kqueue.
 
Back
Top