MrFabio
MrFabio

Reputation: 616

Check FIle Changes

I'm programming in C in unix OS and I'm stuck in a problem. I need to operate in some files selected by the user and check if some token string is in there, but it only makes sense if it checks the file when it is changed. So I thought to use a SIGALARM that every second checks the modification date of the file but it seems that it isn't "good". Is there any other way to do it? OS has any tweak to use in order to become easier?

Thanks.

Upvotes: 0

Views: 80

Answers (1)

Dougvj
Dougvj

Reputation: 6575

On Linux, there is an API called inotify which will do what you want. For a more portable solution, look into the gio sublibrary of glib, specifically here. It might be able to do what you want but I am not completely certain.

Upvotes: 1

Related Questions