简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM