If you're worried about the program failing because the blocks on disk might get removed while it's running, don't. On unix-like systems file data is only purged from disk when the link count reaches 0. Having a file in a directory raises the link count by one. So does having an open file handle for that file. While the program is running, even if the file is removed from the directory where it exists, the link count will still not drop to 0 because there is an open file handle for that file. Only when the program finishes and the file handle to the file is closed will the data be removed from the disk.
If you simply want to stop people removing the file from the directory, just change the permissions:
Note that removing a file from a directory actually only requires write permission to the
directory in which it lives, but AFAIK, most programs will refuse to remove a file with no write permission, or at least warn you about it:
Code:
matthew@chubby:~/tmp$ touch testfile
matthew@chubby:~/tmp$ chmod a-w testfile
matthew@chubby:~/tmp$ ls -l testfile
-r--r--r-- 1 matthew matthew 0 2007-02-05 09:54 testfile
matthew@chubby:~/tmp$ rm testfile
rm: remove write-protected regular empty file `testfile'? n
...although note that the -f (force) option stops this warning:
Code:
matthew@chubby:~/tmp$ rm -f testfile
matthew@chubby:~/tmp$ ls -l testfile
ls: testfile: No such file or directory