Directory updation Notification?

Hi,

I'm a UNIX newbie .. so forgive me if this question sounds dumb.
:slight_smile:

Is it possible for Unix to notify a process that a particular directory has been updated? Rather that the process constantly polling the directory ...

Awaiting your replies ..

Thanks,
VJ

I'm not sure what you mean exactly by "directory has been updated," but I'm pretty sure the answer is no. You would need a daemon (continuously-running background process) to check from time to time. This works OK if (1) performance is not critical and, (2) it's OK to have the notification delayed by a time interval up to X, where X is the period between the checks.

Hi Marc,

Thanks for your reply ..

What i meant by "directory has been updated" was whether a new file has been created in directory ...

Are there no SIGNALS provided by Unix for such a scenario ??
Maybe not ..

Thanks,
VJ

You can see that http://www-900.ibm.com/developerWorks/cn/linux/filesystem/dnotify/index.shtml

If you do not understand Chinese , I suggest you read the programe in middle of the article .

or ,please refer to LXR linux/Documentation/dnotify.txt

or ,you can click "the link" at the bottom of the article

Hi Chenhao,

That was a very informative link. Thanks !!

Is there an equivalent for this in UNIX? or do we have to write our own similar routines ..

Do reply.

Thanks again,
VJ

I agree, that was a very informative link. linux seems to have added some very interesting features.

But I also agree with Marc that standard unix does not have these features.

So you will need to write a monitoring program. Creating a new file entails writing to the directory that contains it. So your program should be able to open the directory, then loop doing a stat() system call and a sleep(). If the mtime of the directory changed, then someting happened. So then the program would scan the directory looking for a new file. This technique will have much less overhead than scanning the directory each loop.

Thanks Perderabo.

Will write some code then.

Thankyou all for the replies.
Good discussion!!

Regards,
VJ