auto update on directory change

Hi all!

Recently I've started to develop a small program that needs to
check for the arrival of files in a pre-determined directory.

I could use a timer to check for changes in this directory every n seconds.

Instead, what I'm really looking for is for some kind of notification mechanism from the OS. I want the application to register for notifications from the OS for any changes in the directory the application is "listening" for.

Any ideas how I could implement this?

Thanks in advance, regards,
Bruno

I suggest you look at opening the approproate directory and use the FD with select. Reading the select man page will help you formulate the strategy and algorithm.