Public bug reported:

Compile the following program (inotifyerr.c)

#include <stdlib.h>
#include <stdio.h>
#include <sys/inotify.h>

int main(int argc, char* argv[]){
    int fd = inotify_init();
    if (fd == -1){
        perror("inotify_init");
    }
    char path[256];
    sprintf(path,"/proc/%s",argv[1]);
    printf("watching %s\n",path);
    int wd = inotify_add_watch(fd,path,IN_ALL_EVENTS);
    if (wd == -1){
        perror("inotify_add_watch");
    }
    char buf[1024];
    ssize_t siz = read(fd,buf,1024);
    if (siz == -1){
        perror("inotify read");
    }
    printf("read done, bytes: %d\n",siz);
}

gcc inotifyerr.c

The program is supposed to watch events occurring on file /proc/nnn, where nnn 
is passed as
argument to program invokation.
Then start a process in background, and watch it with the program above. E.g.

$ sleep 20 &
[1] 8246
$ ls /proc/8246
attr             cpuset   io        mountinfo   pagemap      smaps    wchan
auxv             cwd      latency   mounts      personality  stat
cgroup           environ  limits    mountstats  root         statm
clear_refs       exe      loginuid  net         sched        status
cmdline          fd       maps      oom_adj     schedstat    syscall
coredump_filter  fdinfo   mem       oom_score   sessionid    task
$ ./a.out 8246
watching /proc/8246
^C
[1]+  Done                    sleep 20

Note that the background process and the inotifyerr one are run from
within the same terminal, same user, and that the latter has read
access to the file being watched.
No events are reported.

The expected behaviour of inotify is to report events on /proc files
and directories instead.

Additional information:
I have run the same test also with superuser privileges, but the result
is the same.
I have modified the test program so as to make the process to whatch
a child of the inotifyerr one. In this case inotify catches all the events.

Ubuntu 9.04. 2.6.28-15-generic #52-Ubuntu SMP Wed Sep 9 10:49:34 UTC
2009 i686 GNU/Linux

** Affects: ubuntu
     Importance: Undecided
         Status: New

-- 
inotify does not watch /proc
https://bugs.launchpad.net/bugs/454722
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to