Subject: inotify: IN_IGNORED is not sent

Suppose this code:

i = inotify_init1(IN_CLOEXEC);
wd = inotify_add_watch(i, "/tmp/target2", IN_ATTRIB);
for(;;) {
read (wd, ...);
inotify_rm_watch(i, wd); // FAIL HERE
wd = inotify_add_watch(i, "/tmp/target2", IN_ATTRIB);
}

Now, in shell:
$ :> /tmp/jjj
$ mv /tmp/jjj /tmp/target2

In that case IN_IGNORED is not sent, but wd previously added by
inotify_add_watch() become invalid, so, trying to call
inotify_rm_watch() failed with EINVAL.

--
Segmentation fault