Andrew B. Young wrote: > I need to know when a process as finished writing > a file and has closed it. My only clue is fuser, > which somehow knows what processes have files open. > > Is there a way for me to set a signal on a file's > state that lets me know when it has been closed? > > > Some background-- > > I have a MRI machine that runs GE's canned software > which writes out one new file of image data per second > in a known directory. I need to stream this data > into another process in near-real-time. > > Using [id]notify I can watch the directory and know > when a new file is created. But I need to know when > the file has been closed by the writing process such > that there is no more data to be read. Use /proc. You need to know the process ID of the MRI software: ps -ef | grep might do this for you. Take an example: I'm writing this in vim. Vim is using /tmp/.mutt-kendrick-3668-39.swp as a temporary file. $ ps -ef | grep vim james 3704 3668 0 18:00 pts/1 00:00:00 vim +/^$ /tmp/mutt-kendrick-3668-39 james 3711 3428 0 18:00 pts/2 00:00:00 grep vim $ cd /proc/3704/fd $ ls -l total 4 lrwx------ 1 james james 64 Feb 22 18:00 0 -> /dev/pts/1 lrwx------ 1 james james 64 Feb 22 18:00 1 -> /dev/pts/1 lrwx------ 1 james james 64 Feb 22 18:00 2 -> /dev/pts/1 lrwx------ 1 james james 64 Feb 22 18:00 4 -> /tmp/.mutt-kendrick-3668-39.swp When vim closes the file, fd 4 will go away. Hope this helps, James. -- E-mail address: james | "The letters are Elvish, of an ancient mode, but the @westexe.demon.co.uk | language is that of Microsoft, which I will not utter | here. But this in the Common Tongue is what is said: | By this or any other name, You are well and truly..."