Mattias Brunschen wrote:
In order to do that my software needs to know when a file is written to disk
completely, that is when the process writing down the file (i.e. FTP or the
SMB daemon) closes the file.
[...]
> Are there any ideas to implement this "file was closed" notification?
I have the same problem. A workaround is to see if there are any
processes keeping the file open. I have done this using 'lsof' on Linux.
Here is a hack which does that. Put it in a while loop:
# Get the list from lsof and figure out which files are "free")
dir=my/input
find $dir -type f -maxdepth 1 -print0 | tee tmp | tr \\0 \\n > tmp2
xargs --null /usr/sbin/lsof -Fnp < tmp | grep '^n' | sed 's/^n//' >> tmp2
sort < tmp2 | uniq -c | grep '^ 1' | cut -d1 -f2- | while read f;
echo $f is free
done
|