Re: looking for inotifywait and similar help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patrice Dumas <pertusus@xxxxxxx> 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

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux