looking for inotifywait and similar help
Enrico Scholz
enrico.scholz at informatik.tu-chemnitz.de
Wed Dec 3 19:24:04 UTC 2008
Patrice Dumas <pertusus at free.fr> writes:
>> Beside the syntax error, there is a race when file was created shortly
>> before inotifywait. You have to check whether the file exists *after*
>> inotify_add_watch(2) like in
>>
>> https://www.cvg.de/people/ensc/wait-for-file.c
>
> I don't really understand when the race condition could be,
e.g.
---
d=/tmp/test
test -e $d/file || {
sleep 100
inotifywait -e create $d
}
---
and execute 'touch /tmp/test/file' during the 'sleep 10'.
--> script will hang forever.
In practice, the 'sleep' is shorter but present.
> In both cases /etc is watched. That is something I would have liked to
> avoid, because it will cause my script to wake up a lot,
1. Why make it a script? A small C program makes 3 syscalls per new
file
| $ strace ./a.out /tmp/foo1.c 100000
| ...
| select(4, [3], NULL, NULL, {99987, 966000}) = 1 (in [3], left {99981, 19000})
| read(3, "\1\0\0\0\0\1\0\0\0\0\0\0\20\0\0\0xxcccvf5\0\0\0\0\0\0\0\0", 1024) = 32
| lstat("/tmp/foo1.c", 0x7fffc8d46ed0) = -1 ENOENT (No such file or directory)
2. /etc is not a directory where much file create operations happen
> It looks like signalling that a file came into existence without
> watching the directory the file is in is not possible with inotify
> currently.
No; inotify(7) does not support this operation.
Enrico
More information about the devel
mailing list