Inotify delete_self when changing and saving a file

I am running a small inotify script that sets the clock in a file. Each time this file is edited and saved, the script notices that the DELETE_SELF event is triggered. Is this normal, and if so? Should the inotify subsystem notice that the file still exists?

+3
source share
1 answer

It depends on what the file editing application does. In this case, it seems your editor’s behavior when saving the file is to delete the old file and write the new content as a new file with the same name. From the point of view of inotify, this is exactly what happens, so it fires a delete event, and then a create event. Inotify cannot know that the file that was deleted and the file that was created in its place are logically connected.

+8
source

Source: https://habr.com/ru/post/1743740/


All Articles