Inotify is not working for etc/passwd

I am trying to set listner for passwd file in /etc directory and I am getting notification only for first password change.

fd = inotify_init();
wd = inotify_add_watch (fd, "/etc/passwd", IN_MODIFY);
while(1)
{
 read (fd, buff, BUFF_SIZE);
 struct inotify_event *event = ( struct inotify_event * ) &buff[ i ];
 printf("Event Len -  %d  wd %d \n", event->len, event->wd);
}

why it works first time and not later?I Am seeing timestamp change everytime when I change password. Same set of code working fine for some other file.

Answers


When changing the /etc/passwd, most application create a new file and rename it. This give a new inode number.


Need Your Help

Can I compile Google's protobuf under Visual Studio 11?

c++ protocol-buffers visual-studio-2012

Visual studio 11 (beta) uses the new C++11 standard, which seems to break protobuf. Where I'm stuck at the moment is the way that the C++11 standard defines make_pair. The problem is defined well i...

PHP Displaying output of backend script on active page

javascript php ajax backend

I have a web application in PHP. One component of the application is submitting the data to a backend pipeline (also written in PHP). The pipeline is an external script, which my application calls ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.